nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.91k stars 7.55k forks source link

Running an error after the latest version is released #12417

Closed xxwangkaimin closed 1 year ago

xxwangkaimin commented 1 year ago

Is there an existing issue for this?

Current behavior

node_modules/@nestjs/common/file-stream/streamable-file.js:31 this.options.length ??= bufferOrReadStream.length; ^^^ SyntaxError: Unexpected token '??='

Minimum reproduction code

https://github.com/nestjs/typescript-starter

Steps to reproduce

No response

Expected behavior

normal operation

Package

Other package

No response

NestJS version

10.2.5

Packages versions

"dependencies": {
    "@nestjs-modules/ioredis": "^1.0.1",
    "@nestjs-modules/mailer": "^1.9.1",
    "@nestjs/common": "^10.2.5",
    "@nestjs/config": "^3.1.1",
    "@nestjs/core": "^10.2.5",
    "@nestjs/jwt": "^10.1.1",
    "@nestjs/mapped-types": "*",
    "@nestjs/passport": "^10.0.2",
    "@nestjs/platform-express": "^10.2.5",
    "@nestjs/swagger": "^7.1.11",
    "@nestjs/throttler": "^5.0.0",
    "@nestjs/typeorm": "^10.0.0",
    "axios": "^1.5.0",
    "bcryptjs": "^2.4.3",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "crypto-js": "^4.1.1",
    "dayjs": "^1.11.10",
    "helmet": "^7.0.0",
    "iconv-lite": "^0.6.3",
    "ioredis": "^5.3.2",
    "jssha": "^3.3.1",
    "md5": "^2.3.0",
    "mysql2": "^3.6.1",
    "nanoid": "^5.0.1",
    "node-xlsx": "^0.23.0",
    "nodemailer": "^6.9.5",
    "passport": "^0.6.0",
    "passport-jwt": "^4.0.1",
    "passport-local": "^1.0.0",
    "qiniu": "^7.9.0",
    "qs": "^6.11.2",
    "reflect-metadata": "^0.1.13",
    "request-ip": "^3.3.0",
    "rxjs": "^7.8.1",
    "svg-captcha": "^1.4.0",
    "systeminformation": "^5.21.8",
    "typeorm": "^0.3.17",
    "ua-parser-js": "^1.0.36",
    "uuid": "^9.0.1"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.1.18",
    "@nestjs/schematics": "^10.0.2",
    "@nestjs/testing": "^10.2.5",
    "@types/crypto-js": "^4.1.2",
    "@types/express": "^4.17.17",
    "@types/jest": "29.5.5",
    "@types/multer": "^1.4.7",
    "@types/node": "20.6.3",
    "@types/passport-jwt": "^3.0.9",
    "@types/passport-local": "^1.0.35",
    "@types/request-ip": "^0.0.38",
    "@types/supertest": "^2.0.12",
    "@types/ua-parser-js": "^0.7.37",
    "@types/uuid": "^9.0.4",
    "@typescript-eslint/eslint-plugin": "^6.7.2",
    "@typescript-eslint/parser": "^6.7.2",
    "cross-env": "^7.0.3",
    "eslint": "^8.49.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "29.7.0",
    "prettier": "^3.0.3",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "29.1.1",
    "ts-loader": "^9.4.4",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "4.2.0",
    "typescript": "^5.2.2"
  }

Node.js version

18.18.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

What version of Node do you use? AFAIR ??= assignment operator was added in v15/v16 so you shouldn't see any errors on Node 18

xxwangkaimin commented 1 year ago

您使用什么版本的节点?AFAIR ??= 赋值运算符已在 v15/v16 中添加,因此您不应在 Node 18 上看到任何错误 1695307148165 1695307316953

xxwangkaimin commented 1 year ago

What version of Node do you use? AFAIR ??= assignment operator was added in v15/v16 so you shouldn't see any errors on Node 18

I use PM2 for project initiation json module.exports = { apps: [ { name: 'nest-manage-stage', script: 'dist/main.js', args: '', watch: true, ignore_watch: ['node_modules', 'public', 'logs'], exec_mode: 'cluster_mode', instances: '1', autorestart: true, max_memory_restart: '500M', merge_logs: true, log_date_format: 'YYYY-MM-DD HH:mm:ss', min_uptime: '60s', max_restarts: 30, restart_delay: 60, env_staging: { NODE_ENV: 'staging', PORT: '4000', } ] } start command: "pm2:stage": "pm2 start ecosystem.config.js --env staging"

micalevisk commented 1 year ago

@xxwangkaimin Make sure you are using nodejs v16 or greater. That's required in Nestjs v10

xxwangkaimin commented 1 year ago

@xxwangkaimin Make sure you are using nodejs v16 or greater. That's required in Nestjs v10

The nodejs version in Linux services is 18.18.0

jmcdo29 commented 1 year ago

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

why reproductions are required


Most of us are using nest's latest version without an issue on node 16+. Whatever is going on seems to be localized and we need a way to actually reproduce it

micalevisk commented 1 year ago

@xxwangkaimin please run this in your terminal:

node -v
node -p "let a; a ??= 123"

you should see 123

Everything went fine here in v18.15.0 on Linux

xxwangkaimin commented 1 year ago

@xxwangkaimin please run this in your terminal:

node -v
node -p "let a; a ??= 123"

you should see 123

Everything went fine here in v18.15.0 on Linux

I can output 123 according to your method

micalevisk commented 1 year ago

@xxwangkaimin in that case, share some full code that reproduces your issue along with the steps to reproduce it.

xxwangkaimin commented 1 year ago

@xxwangkaimin in that case, share some full code that reproduces your issue along with the steps to reproduce it.

I used npm i - legacy peer deps when installing dependencies, but I'm not sure if it's related to this.I have no problem developing and running locally. Once packaged and released for production, it won't work

jmcdo29 commented 1 year ago

Where do you deploy for production? Is it using the same node version as you use for development?

xxwangkaimin commented 1 year ago

Where do you deploy for production? Is it using the same node version as you use for development?

I released production on an Alibaba Cloud Linux server, and the node versions of the production and development environments are consistent

xxwangkaimin commented 1 year ago

请提供最小复制存储库(Git 存储库/ StackBlitz / CodeSandbox项目)。

为什么需要复制品

我们大多数人都使用 Nest 的最新版本,在 Node 16+ 上没有出现问题。无论发生什么似乎都是本地化的,我们需要一种方法来实际重现它

I created a basic project using the command line to publish a project in the production environment. The basic project created with the command 'next new project-name' does not have any other features and there are no issues with the development environment. If I directly publish it to the production environment, an error will be reported

jmcdo29 commented 1 year ago

This is purely an issue with your production environment not using the versions expected. We cannot debug this without knowing all the details. Now then likely pm2 is using some other node version then expected. Why? No clue, we don't have access to that. But this is not an issue with the framework

xxwangkaimin commented 1 year ago

This is purely an issue with your production environment not using the versions expected. We cannot debug this without knowing all the details. Now then likely pm2 is using some other node version then expected. Why? No clue, we don't have access to that. But this is not an issue with the framework

However, upgrading the version of Nodejs in the production environment from v16 to v18 has no effect

TracyLDavidson commented 11 months ago

@xxwangkaimin Make sure you are using nodejs v16 or greater. That's required in Nestjs v10

This worked for me! Thank you!

edsonsantosilva commented 10 months ago

Updating for Node 18 also worked for me

dingyl666 commented 7 months ago

解决了吗,我用阿里云的服务器也遇到这个问题了

xxwangkaimin commented 7 months ago

@dingyl666 我是阿里云服务器升级pm2到最新版本解决的

dingyl666 commented 7 months ago

@dingyl666我是阿里云服务器升级pm2到最新版本解决的

我的pm2就是最新版本 不过我已经解决了 执行了一下pm2 kill就莫名其妙的好了

floruitShow2 commented 7 months ago

@dingyl666 我是阿里云服务器升级pm2到最新版本解决的

兄弟,你用的pm2哪个版本啊,我安装最新版依然有这个报错

xxwangkaimin commented 6 months ago

@floruitShow2 我当时更新的时候pm2最新版本是 5.3.0