美文网首页
Nest创建项目时报错

Nest创建项目时报错

作者: 星星藏进黑夜 | 来源:发表于2024-03-31 13:05 被阅读0次

报错信息

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

相关文章

网友评论

      本文标题:Nest创建项目时报错

      本文链接:https://www.haomeiwen.com/subject/bltbtjtx.html