After I installed Nest globally, I tried creating a new project but I got this error Failed to execute command: npm install --silent.
nest new new_project
Same here. No answer was helpful to me. I got it working by:
nest new test-project
cd test-project
npm install @types/jest@27.0.1
npm install
Is a problem whit Urix module https://github.com/lydell/urix#deprecated
Try:
npm cache clean --force
npm i -g source-map-resolve
npm i -g @nestjs/cli
nest new project_name
I was getting the same error using an older version of Node (v12.7.0) and using Yarn (v1.22.5).
I fixed the problem by using nvm to install the long-term support (LTS) version of Node and then reinstalling the Nest CLI.
nvm install --lts
npm install -g @nestjs/cli
I encountered this issue on my Linux desktop.
When the error occurs?
The error occurs after the nest CLI created the project skeleton and moved to the dependencies installation with npm
/ yarn
.
Debugging
After running next new <project-name>
I accessed the new create folder (project-name) and tried to run npm install
from there:
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 "/home/my-user/.npm"
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /home/my-user/.npm/_cacache/tmp/ef585472
npm ERR! errno -13
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 "/home/my-user/.npm"
The cause of the error
The problem in my case was related to permissions to the _cache
folder inside the .npm
folder of the current user path.
Solution:
I fixed this by simply running:
sudo chown -R 1000:1000 /home/my-user/.npm/_cache
Then running npm install
inside the failed project folder.
On new project the problem should not occur.
Additional information:
1 ) Running npm cache clean --force
gave me the exact same error which npm install
produced.
2 ) Running next new <project-name>
with sudo
might be a workaround but it is better to solve the permissions issues without running the process with sudo
.
Versions I used:
I'm working with:
$nest -v
7.5.3
$node -v
v12.19.0
If create project with yarn package:
- 1: Run cmd: npm install -g yarn
- 2: Run again: nest new <project> then
choice yarn
I got the same error.
Failed to execute command: npm install --silent
× Installation in progress... ☕
Packages installation failed, see above
I have tried all the solution mentioned here nothing worked for me, so I decided to uninstall node and reinstall it.
To uninstall node I refer this https://stackoverflow.com/a/20711410/15543025.
Previously i was using
node version: 16.6.2
npm version: 7.20.6
After uninstalling node I installed LTS version of node(i.e v14.17.5), it includes npm version: 6.14.14.
Don't know what the actual problem was but it is working fine on older versions of npm. This could be a possible workaround.
In my case just reinstalling @nestjs/cli fixed it.
npm install -g @nestjs/cli
I fix it by install yarn globally.
I just execute this command: npm install -g yarn
After that I execute create new nestjs app and it work:
nest new nestjs-app
If you are on a mac it might be possible that you have installed node with brew. In this case try to remove this by uninstalling node:
brew uninstall --force node
Then install node again using the official website: https://nodejs.org/en/
In my case I had 2 installations of node running which caused this error.
I hope it helps!
This could result from yarn not being installed. try installing yarn with npm:
npm install --global yarn
you might have to add sudo depending on the permissions
sudo npm install --global yarn
Instead of running npm cache clean --force
Run npm i -g -f pnpm
Couldn't find the answer anywhere, figured it out by trying things out.
This is the issue between conflicts of versions of nodejs and nestjs
I had the same issue . I then updated my node version to lattest LTS and then installed nest-cli globbaly. everything then works perfectly. This is not the problem with your OS it is with internal dependencies of NestJS
Try to run the cmd as administrator, and run the command again.
If it didn't help, re-install the nest-cli
package as an administrator, then run nest new project-name
.
Just use "sudo"
sudo nest new <project-name>