javascript npm 安装,-force 标志
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52001771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install, -force flag
提问by Willem van der Veen
I was installing the packages on a NodeJS backend. Then I run into an error which was the following:
我在 NodeJS 后端安装软件包。然后我遇到了一个错误,如下所示:
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.
gyp.js”重建gyp ERR!配置错误gyp ERR!堆栈错误:找不到Python可执行文件“python”,您可以设置PYT HON env变量。
It said I need some python executable. However when I run:
它说我需要一些 python 可执行文件。但是,当我运行时:
npm i -force
Everything installs seems to be working fine.
一切安装似乎工作正常。
Questions:
问题:
- How is
npm i -forcedifferent from a normalnpm i? - Are there any troubles which can arise in future scenarios due to this approach?
- 如何
npm i -force从一个正常的不同npm i? - 由于这种方法,在未来的场景中是否会出现任何问题?
采纳答案by Svetoslav Petrov
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.
就像 Liam 提到的 -force "forces" npm 以重新下载所有软件包并再次安装它们。可能由此产生的问题是,显然如果您有太多的包,每次下载它们都需要更多的时间。
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.
对于关于 gyp.js 的具体问题,据我所知,node-gyp 在 $HOME 目录中下载了一些东西,我假设你的情况下的路径有一些空格。有些工具不处理路径中的空格,这就是它找不到可执行文件的原因。
Other possible solutions:
其他可能的解决方案:
delete the $HOME/.node_gyp folder and run
npm updateinstall the libkrb5-dev package
sudo apt-get install libkrb5-devinstall the build-essential package
sudo apt-get install build-essential
删除 $HOME/.node_gyp 文件夹并运行
npm update安装 libkrb5-dev 包
sudo apt-get install libkrb5-dev安装 build-essential 包
sudo apt-get install build-essential

