【问题标题】:NestJS Project on Google App Engine shows error "Could not write file" && " EROFS: read-only file system"Google App Engine 上的 NestJS 项目显示错误“无法写入文件”&&“EROFS:只读文件系统”
【发布时间】:2023-04-01 16:45:01
【问题描述】:

当我在 Google App 引擎上部署 NestJS 项目时,我正在努力解决如下错误。

错误 TS5033:无法写入文件 '/workspace/dist/properties/dto/property.filter.dto.d.ts':EROFS:只读文件系统,打开 '/workspace/dist/properties/dto/ property.filter.dto.d.ts'。

app.yaml 文件在下面

runtime: nodejs10
env: standard

default_expiration: "4d 5h"

## to specify database
beta_settings:
  cloud_sql_instances: "your instance connection name"

env_variables:
  DATABASE_HOST: "/cloudsql/your instance connection name"
  DATABASE_USERNAME: "user name"
  DATABASE_PASSWORD: "password"
  INSTANCE_CONNECTION_NAME: "your instance connection name"

handlers:
- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

tsconfig.json 文件在下面

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "ES2017",
    "sourceMap": true,
    "outDir": "./dist",
    "allowJs": true,
    "baseUrl": "./",
    "incremental": true
  }
}

似乎我无法在 App Engine 上的 dist 文件夹中写入文件,但我不知道为什么会这样。

【问题讨论】:

    标签: node.js typescript google-app-engine nestjs


    【解决方案1】:

    正如official documentation 所示:

    Java 8、Java 11、Node.js、Python 3、PHP 7、Ruby、Go 1.11 和 Go 1.12+ 对 /tmp 目录具有读写权限。

    因此,这意味着只有在 /tmp 目录中,您才能执行写入操作,而其他您不能执行的操作,因为它们是只读的,其中包括 workspacedist .正如在类似案例here 的答案中所阐明的那样,您将需要在/tmp 目录中处理您的文件,或者开始使用App Engine Flex,您可以在其中写入其他目录。

    【讨论】:

    • 感谢您对 gso_gabriel 的评论。但我不明白你的意思,因为我刚刚部署了 nestJS 项目,并且在我的本地没有工作区目录。如果你能告诉我如何处理 /tmp 目录中的文件“谢谢
    • 您好,刚刚更新的 package.json 解决了这个问题。我刚刚将启动脚本修改为node dist/main.js,然后应用程序运行成功,谢谢。
    猜你喜欢
    • 2021-07-20
    • 2020-07-10
    • 2018-04-09
    • 2020-05-18
    • 2018-12-20
    • 2015-06-08
    • 2016-01-23
    • 1970-01-01
    • 2022-12-15
    相关资源
    最近更新 更多