Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJs: Failed to execute command: npm install --silent

Tags:

node.js

nestjs

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
like image 442
DiaMaBo Avatar asked Jul 19 '19 14:07

DiaMaBo


4 Answers

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
like image 78
Ehrlich_Bachman Avatar answered Sep 18 '22 08:09

Ehrlich_Bachman


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
like image 40
Gianmar Avatar answered Sep 21 '22 08:09

Gianmar


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
like image 29
RtmY Avatar answered Sep 18 '22 08:09

RtmY


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
like image 26
Solidus Snake Avatar answered Sep 19 '22 08:09

Solidus Snake