NestJS Project on Google App Engine shows error "Could not write file" && " EROFS: read-only file system"

Viewed 754

I am struggling to solve error as like below when i deploy NestJS project on Google App engine.

error TS5033: Could not write file '/workspace/dist/properties/dto/property.filter.dto.d.ts': EROFS: read-only file system, open '/workspace/dist/properties/dto/property.filter.dto.d.ts'.

app.yaml file is below

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 file is below

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

it seems i can not write files in dist folder on App Engine but i am not sure why it happens.

1 Answers

As this official documentation indicates:

Java 8, Java 11, Node.js, Python 3, PHP 7, Ruby, Go 1.11, and Go 1.12+ have read and write access to the /tmp directory.

So, this means that only in the /tmp directory you will be able to perform writting operations and any others you won't as they arey read-only, which will include the workspace and consequently the dist. As clarified in this answer from a similar case here, you will need to handle your files in either the /tmp directory or start to use App Engine Flex, where you can write in other directories.

Related