Search code examples
javascriptnode.jsnpmnpm-install

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?

Solution

  • 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