报错信息
C:\Users\dream\AppData\Roaming\npm\node_modules\@nestjs\cli\node_modules\.store\@angular-devkit+schematics-cli@17.1.2\node_modules\@angular-devkit\schematics-cli\bin\schematics.js:451
load ??= new Function('modulePath', `return import(modulePath);`);
^^^
SyntaxError: Unexpected token '??='
at wrapSafe (internal/modules/cjs/loader.js:1029:16)
at Module._compile (internal/modules/cjs/loader.js:1078:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47
Failed to execute command: node @nestjs/schematics:application --name=nest-project --directory=undefined --no-dry-run --no-skip-git --no-strict --package-manager="yarn" --collection="@nestjs/schematics" --language="ts"
原因
Nest文档地址 https://nest.nodejs.cn/first-steps
文档中表明安装的Node.js必须是>= 16的版本
解决方案
- 可以卸载node后进行重装>= 16的版本
- 通过nvm管理nodejs,这样电脑就可以存在多个版本的nodejs
网友评论