Nest创建项目时报错

报错信息

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的版本

image.png

解决方案

  1. 可以卸载node后进行重装>= 16的版本
  2. 通过nvm管理nodejs,这样电脑就可以存在多个版本的nodejs
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容