node.js 无法使用 npm 安装预渲染 - “无法定位:CL.exe”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33239445/
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
could not install prerender using npm - "Failed to locate: CL.exe"
提问by Karl Cassar
I've been trying to install PreRender.Ioon my local machine to test. I've installed Python 2.7.10. When I type:
我一直在尝试安装PreRender.Io在我的本地机器上进行测试。我已经安装了 Python 2.7.10。当我输入:
npm install prerender
npm install prerender
It gives an error:
它给出了一个错误:
C:\PreRender\node_modules\prerender\node_modules\phantom\node_modules\dnode\node
_modules\weak>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\
node_modules\npm\bin\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js"
rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the
file specified. [C:\PreRender\node_modules\prerender\node_modules\phantom\node
_modules\dnode\node_modules\weak\build\weakref.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074
:12)
gyp ERR! System Windows_NT 6.1.7601
I couldn't locate CL.exe, and a quick search on Google seems to be some missing Visual C++ compiler. However, I tried installing say VC++ 2008 redistributable x86, but still same problem.
我找不到 CL.exe,在 Google 上快速搜索似乎缺少一些 Visual C++ 编译器。但是,我尝试安装说 VC++ 2008 可再发行的 x86,但仍然存在同样的问题。
Any idea what could be wrong? OS is Windows 7 64-bit.
知道有什么问题吗?操作系统是 Windows 7 64 位。
回答by Karl Cassar
I've managed to solve the problem, although it was quite strange. Honestly, I'm not sure which one solved it completely as I've done quite some stuff. I had installed Visual Studio 2015 on my machine. Below is a summary of what I've done:
我设法解决了这个问题,虽然这很奇怪。老实说,我不确定哪一个完全解决了它,因为我已经做了很多事情。我已经在我的机器上安装了 Visual Studio 2015。下面是我所做的总结:
Installed Visual C++ Compiler, from the VS 2015 installation. By default it was unticked. I think this is what fixed the issue.
Added the path where CL.exe
(C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin)and stdlib.h(C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include)are located to the PATHenvironment variable.- Executed the
npm install prerenderfrom theDeveloper Command Promptin of Visual Studio 2015, running in Administrator mode
从 VS 2015 安装安装Visual C++ Compiler。默认情况下它是未选中的。我认为这就是解决问题的原因。
将CL.exe
(C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin)和stdlib.h所在的路径添加(C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include)到PATH环境变量中。- 执行
npm install prerender从Developer Command Prompt在Visual Studio 2015年,在运行管理模式
回答by Antfish
I'm just going through an Angular JS tutorial and had this issue, but their docs suggest it isn't a problem:
我正在阅读 Angular JS 教程并遇到了这个问题,但他们的文档表明这不是问题:
"We often see an npm WARN message after a series of gyp ERR! messages. Ignore them. A package may try to re-compile itself using node-gyp. If the re-compile fails, the package recovers (typically with a pre-built version) and everything works."
“我们经常在一系列 gyp ERR! 消息之后看到 npm WARN 消息。忽略它们。一个包可能会尝试使用 node-gyp 重新编译自己。如果重新编译失败,包会恢复(通常带有预内置版本),一切正常。”
回答by johnstaveley
For me the problem came after installing a new version of node. npm install would show the error above. Then I got the error above but not for the package PreRender.Io but for gulp-sass, though I believe the problem has the same root. To solve it, I installed the previous version of node I'd been using (6.9.5) and then I used nvm to manage node versions as described here: https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
对我来说,问题是在安装新版本的节点后出现的。npm install 会显示上面的错误。然后我得到了上面的错误,但不是针对 PreRender.Io 包,而是针对 gulp-sass,尽管我相信问题有相同的根源。为了解决这个问题,我安装了我一直在使用的以前版本的节点(6.9.5),然后我使用 nvm 来管理节点版本,如下所述:https://www.sitepoint.com/quick-tip-multiple-版本-节点-nvm/
Switching to the previous version of node using nvm meant I could do npm install without having to install a large SDK I wasn't going to end up using.
使用 nvm 切换到以前版本的 node 意味着我可以执行 npm install ,而无需安装我最终不会使用的大型 SDK。

