首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >上的NestJS项目显示错误“无法写入文件”

上的NestJS项目显示错误“无法写入文件”
EN

Stack Overflow用户
提问于 2021-04-27 13:40:51
回答 1查看 287关注 0票数 1

我尝试用标准env实例在app引擎中部署我的nestJS应用程序。但是我收到了这个错误:

代码语言:javascript
复制
0mCould not write file '/workspace/dist/my/ts/file': EROFS: read-only file system, open '/workspace/dist/my/ts/file'. 

我知道nodejs只能在/tmp目录中执行写入操作。

我的问题是:如何将工作区文件夹(由云构建创建)放入tmp文件夹

这是我的app.yaml

代码语言:javascript
复制
runtime: nodejs12
env: standard

我的package.json

代码语言:javascript
复制
{
  "name": "elengui-api",
  "version": "2.0.0",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "npx @nestjs/cli build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "npx @nestjs/cli start",
    "start:dev": "npx @nestjs/cli start --watch",
    "start:debug": "npx @nestjs/cli start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json",
    "gcp-build": "npm run build",
    "deploy": "gcloud app deploy"
  },
  "dependencies": {
    "@hapi/joi": "^17.1.1",
    "@nestjs/common": "^7.5.1",
    "@nestjs/config": "^0.6.3",
    "@nestjs/core": "^7.5.1",
    "@nestjs/jwt": "^7.2.0",
    "@nestjs/mapped-types": "^0.3.0",
    "@nestjs/passport": "^7.1.5",
    "@nestjs/platform-express": "^7.5.1",
    "@nestjs/schedule": "^0.4.3",
    "@nestjs/swagger": "^4.7.13",
    "@nestjs/throttler": "^1.1.3",
    "@nestjs/typeorm": "^7.1.5",
    "@types/bcrypt": "^3.0.0",
    "@types/cookie-parser": "^1.4.2",
    "@types/hapi__joi": "^17.1.6",
    "@types/nodemailer": "^6.4.0",
    "@types/passport": "^1.0.6",
    "@types/passport-jwt": "^3.0.4",
    "@types/passport-local": "^1.0.33",
    "bcrypt": "^5.0.0",
    "class-transformer": "^0.4.0",
    "class-validator": "^0.13.1",
    "cookie-parser": "^1.4.5",
    "crypto-random-string": "^3.3.1",
    "csurf": "^1.11.0",
    "express": "^4.17.1",
    "hbs": "^4.1.1",
    "helmet": "^4.4.1",
    "mysql2": "^2.2.5",
    "nodemailer": "^6.5.0",
    "passport": "^0.4.1",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "path": "^0.12.7",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^6.6.3",
    "swagger-ui-express": "^4.1.6",
    "typeorm": "^0.2.31"
  },
  "devDependencies": {
    "@nestjs/cli": "^7.5.4",
    "@nestjs/schematics": "^7.1.3",
    "@nestjs/testing": "^7.5.1",
    "@types/cron": "^1.7.2",
    "@types/express": "^4.17.11",
    "@types/jest": "^26.0.15",
    "@types/node": "^14.14.6",
    "@types/supertest": "^2.0.10",
    "@typescript-eslint/eslint-plugin": "^4.6.1",
    "@typescript-eslint/parser": "^4.6.1",
    "eslint": "^7.12.1",
    "eslint-config-prettier": "7.2.0",
    "eslint-plugin-prettier": "^3.1.4",
    "jest": "^26.6.3",
    "prettier": "^2.1.2",
    "supertest": "^6.0.0",
    "ts-jest": "^26.4.3",
    "ts-loader": "^8.0.8",
    "ts-node": "^9.0.0",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.0.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2021-04-28 08:27:55

此错误的解释是试图写入目录不同的/tmp

正式文件包含以下内容:

虽然Cloud是在App中读写文件的推荐解决方案,但如果应用程序只需要编写临时文件,则可以使用标准的Node.js方法将文件写入名为/tmp的目录。

这就是错误,似乎您的代码正在尝试使用错误信息中提到的目录。我手头上没有游戏组,但我认为这与使用startnpx脚本有关。您应该使用node <your-app.js>代替。我发现了不同的问题,问题海报证实了这一点。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67284226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档