Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install, -force flag

I was installing the packages on a NodeJS backend. Then I run into an error which was the following:

gyp.js" rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable.

It said I need some python executable. However when I run:

npm i -force

Everything installs seems to be working fine.

Questions:

  1. How is npm i -force different from a normal npm i?
  2. Are there any troubles which can arise in future scenarios due to this approach?
like image 839
Willem van der Veen Avatar asked Aug 24 '18 09:08

Willem van der Veen


People also ask

What is flag in npm command?

npm install -s. The -s flag is a shorthand for the silent configuration, which sets the log level of your npm installation process to nothing. The following Terminal commands are all equal: npm install -s npm install --silent npm install --loglevel silent.

What is npm global install?

A global install will instead put the module into your global package folder (OS dependent), and allows you to run the included executable commands from anywhere. Note that by default you can only require local packages in your code. See the node.


1 Answers

Like Liam has mentioned -force "forces" npm to re-download all packages and install them again. The issue that may arise from that is that obviously if you have too many packages it takes more time to download them each time.

For the specific issue regarding gyp.js as far as I know node-gyp downloads some stuff in the $HOME directory and I assume the path in your case has some spaces. Some tools do not handle spaces in paths which is why it cannot find the executable.

Other possible solutions:

  • delete the $HOME/.node_gyp folder and run npm update

  • install the libkrb5-dev package sudo apt-get install libkrb5-dev

  • install the build-essential package sudo apt-get install build-essential

like image 200
Svetoslav Petrov Avatar answered Sep 23 '22 07:09

Svetoslav Petrov