11

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
Rot-man
  • 18,045
  • 12
  • 118
  • 124
DiaMaBo
  • 1,879
  • 1
  • 18
  • 18

16 Answers16

14

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
Ehrlich_Bachman
  • 772
  • 1
  • 10
  • 23
  • 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` – Elias Salom Feb 22 '23 at 17:05
7

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
Gianmar
  • 505
  • 3
  • 13
  • 1
    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. – Leonardo Souza Paiva Feb 22 '21 at 17:49
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
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
Rot-man
  • 18,045
  • 12
  • 118
  • 124
2

If create project with yarn package:

 - 1: Run cmd: npm install -g yarn 
 - 2: Run again: nest new <project> then
   choice yarn
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.

Jay Godhani
  • 368
  • 2
  • 12
1

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

npm install -g @nestjs/cli
Lars Flieger
  • 2,421
  • 1
  • 12
  • 34
1

Run this command first

npm cache clean --force

Then try to create new project using this command

nest new project-name
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Ima
  • 31
  • 2
1

I fixed it by running

nvm use stable 
nest new app-name
Exodus Reed
  • 177
  • 1
  • 10
0

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

0

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!

Marco Koopman
  • 126
  • 2
  • 14
0

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
pyamo
  • 1
  • 1
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.

Raush
  • 121
  • 1
  • 2
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

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.

Tzahi Leh
  • 2,002
  • 1
  • 15
  • 27
-1

Just use "sudo"

sudo nest new <project-name>
Javid
  • 1
  • 1
    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](/help/how-to-answer). – Community May 18 '23 at 10:52