13

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

19 Answers 19

16

Same here. No answer was helpful to me. I got it working by:

nest new test-project
cd test-project
npm install @types/[email protected]
npm install
Sign up to request clarification or add additional context in comments.

3 Comments

this happened to me because permissions issue in my home directory and I solved it by making the npm have permissions by this command sudo chown -R $(whoami) ~/.npm
Hinting from @EliasSalom comment, I just did :- sudo nest new project and it solved the issue.
This should be the answer
8

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

1 Comment

running npm cache clean --force i got a message to copy and paste with a sudo chown -R recomended, then i followed as you said, and it worked, thanks.
3

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

Comments

2

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

Comments

2

If create project with yarn package:

 - 1: Run cmd: npm install -g yarn 
 - 2: Run again: nest new <project> then
   choice yarn

Comments

2

I fixed it by running

nvm use stable 
nest new app-name

Comments

1

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.

Comments

1

In my case just reinstalling @nestjs/cli fixed it.

npm install -g @nestjs/cli

Comments

1

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

Comments

1

Run this command first

npm cache clean --force

Then try to create new project using this command

nest new project-name

Comments

1

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!

Comments

1

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

Comments

0

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.

Comments

0

Just use "sudo"

sudo nest new <project-name>

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
worked, voted for you
0

This is the issue between conflicts of versions of nodejs and nestjs

  1. If you want to work with new version of nestjs then update your nodejs version to latest LTS.
  2. if you want to work with older version then install previous supported cli version and nestjs app.

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

Comments

0

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.

Comments

0

sudo nest new project-name

try to create the project with admin privileges using sudo at the start. this worked for me

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

For me updating node version worked (with nvm):

nvm install --lts
node -v
npm i -g @nestjs/cli
npm install --global yarn
nest new project-name

Comments

0

I encountered this issue, what I realized was that I had installed yarn globally and it had created a package.json and a yarn.lock file in my user directory which was causing some form of conflicts with the creation of new project. I solved this issue by removing both package.json and the yarn.lock file

rm /Users/your_username/package.json

rm /Users/your_username/yarn.lock

After that, switch to your project directory and run;

yarn install

or

npm install

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.