Reputation: 296
I'm trying to learn NestJS and just following simple tutorial to create nestjs app.
Getting following error while executing cli command nest new test-project
NestJS cli Version: 7.1.5 NodeJS Version: v10.18.1
Error:
Error: Collection "@nestjs/schematics" cannot be resolved.
at NodeModulesEngineHost.resolve (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:74:19)
at NodeModulesEngineHost._resolveCollectionPath (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:79:37)
at NodeModulesEngineHost.createCollectionDescription (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:109:27)
at SchematicEngine._createCollectionDescription (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/src/engine/engine.js:147:40)
at SchematicEngine.createCollection (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/src/engine/engine.js:140:43)
at NodeWorkflow.execute (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics/src/workflow/base.js:100:41)
at main (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:224:24)
at Object.<anonymous> (/Users/tsuthar/.config/yarn/global/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:315:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Failed to execute command: "/Users/tsuthar/.config/yarn/global/node_modules/@nestjs/cli/node_modules/.bin/schematics" @nestjs/schematics:application --name=nestjs-task-management --directory=undefined --no-dry-run --no-skip-git --package-manager=undefined --language="ts" --collection="@nestjs/schematics"
Upvotes: 21
Views: 19558
Reputation: 1
I just upgraded @nestjs/cli and @nestjs/schematics to the latest version which is :
and it worked for me
Upvotes: 0
Reputation: 1
If you have the following problem
> yarn global add @nestjs/schematics
yarn global v1.22.21
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
error @angular-devkit/[email protected]: The engine "node" is incompatible with this module. Expected version "^18.13.0 || >=20.9.0". Got "16.20.2"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
Try to install the same version of @nestjs/cli
as the @nestjs/schematics
.
I install cli using yarn global add @nestjs/[email protected]
so I have to install schematics using yarn global add @nestjs/[email protected]
Upvotes: 0
Reputation: 11
I was getting the same error for mine but i was using npm instead of yarn i just updated my node version cause Nestjs uses node version of 12 and above
Upvotes: 1
Reputation: 4283
To keep using yarn, this worked for me https://github.com/nestjs/nest-cli/issues/613#issuecomment-602235328
yarn global add @nestjs/schematics
Upvotes: 26
Reputation: 1
Install this NPM package works for me,
apollo-server-core: 3.7.0
https://www.npmjs.com/package/apollo-server-core
Upvotes: -1
Reputation: 1124
I got the same error when creating a new nestJS
project with yarn
. What worked for me is doing the following:
yarn cache clean
yarn global remove @nestjs/cli
yarn global add @nestjs/cli
nest new project-name
yarn
when given an option to choose package managerAs @Abderrahmane TAHRI JOUTI mentioned I followed the link and the above solution worked for me.
https://github.com/nestjs/nest-cli/issues/613#issuecomment-602235328
Upvotes: 1
Reputation: 685
What worked for me was 2 lines of code -
yarn add @nestjs/schematics
nest new your-project-name
Upvotes: 3
Reputation: 4388
I had the same problem. same error
message.
I installed nest with yarn so I use command bellow to add(install) shematics:
yarn global add @nestjs/schematics
If you use npm use this
npm i -g @nestjs/schematics
Upvotes: 9
Reputation: 2970
I faced this issure recently and none of the suggested issues worked for me. I tried using npm to install @nestjs/cli and also tried to remove @nestjs/cli and reinstall using yarn global add @nestjs/schematics
.
Finally a hit and trial that did work for me to run the following command using only and only npm
npm i -g @nestjs/schematics
After this when I tried to create my project using nest new cli command, it worked like a charm. After that you're free to choose and use npm or yarn as per your convenience.
Upvotes: 1
Reputation: 296
Initially, I added NestJS cli with yarn and it gave the above error. The issue gets fixed as soon as I've installed NestJS cli with Npm after removing it from yarn.
Upvotes: 2