could not install prerender using npm - “Failed to locate: CL.exe”

℡╲_俬逩灬. 提交于 2020-01-10 08:40:34

问题


I've been trying to install PreRender.Io on my local machine to test. I've installed Python 2.7.10. When I type:

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\14.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.

Any idea what could be wrong? OS is Windows 7 64-bit.


回答1:


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:

  • 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 PATH environment variable.

  • Executed the npm install prerender from the Developer Command Prompt in of Visual Studio 2015, running in Administrator mode



回答2:


I'm just going through an Angular JS tutorial and had this issue, but their docs suggest it isn't a problem:

"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."

https://angular.io/guide/quickstart




回答3:


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/

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.



来源:https://stackoverflow.com/questions/33239445/could-not-install-prerender-using-npm-failed-to-locate-cl-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!