在Windows中使用NPM和node-gyp进行故障排除
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Windows中使用NPM和node-gyp进行故障排除相关的知识,希望对你有一定的参考价值。
我的Windows工作站上的npm软件包有些麻烦...我的package.json
文件中有一组NPM依赖项:
"devDependencies": { "babel-plugin-transform-react-jsx": "^6.2.0", "babel-preset-es2015": "^6.1.18", "babel-preset-react": "^6.1.18", "grunt": "^0.4.5", "grunt-babel": "^6.0.0", "grunt-contrib-connect": "^0.11.2", "grunt-contrib-jasmine": "^0.9.2", "grunt-contrib-sass": "^0.9.2", "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", "grunt-template-jasmine-requirejs": "^0.2.3", "karma-chrome-launcher": "^0.2.2", "karma-firefox-launcher": "^0.1.7", "karma-requirejs": "^0.2.2", "requirejs": "^2.1.22", "grunt-contrib-jshint": "^0.11.3", "grunt-karma": "^0.12.1", "karma": "^0.13.15", "karma-jasmine": "^0.3.6", "karma-phantomjs-launcher": "^0.2.1" }
当我试图运行npm install
时,我得到了与node-gyp
包有关的奇怪错误,以及msbuild.exe
之类的东西。
这是错误:
c:Usersdmytro.medvidsitesevolution ode_modulesutf-8-validate>if not defined npm_config_node_gyp (node "c:Program Files odejs ode_modules pmin ode-gyp -bin\.... ode_modules ode-gypin ode-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. c:Usersdmytro.medvidsitesevolution ode_modulesutf-8-validateuildvalidation.vcxproj(20,3): error MSB4019: The imported project "c:Microsoft.Cpp.Default. props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. gyp ERR! build error gyp ERR! stack Error: `C:windowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (c:Program Files odejs ode_modules pm ode_modules ode-gyplibuild.js:270:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd c:Usersdmytro.medvidsitesevolution ode_modulesutf-8-validate gyp ERR! node -v v5.1.0 gyp ERR! node-gyp -v v3.0.3 gyp ERR! not ok npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: `node-gyp rebuild` npm WARN install:utf-8-validate@1.2.1 Exit status 1 npm WARN EPACKAGEJSON evolution@1.0.0 No repository field.
有人可以帮助解决问题吗?我没有经验丰富的Windows用户,但此刻我应该使用Windows :(
更新:这是我每次更新新的NPM错误时更新的errors log。
系统详细信息:Windows 7 Enterprise 64位操作系统
节点版本:v5.1.0
NPM版本:v3.3.12
Python版本:v2.7.1
我也安装了Microsoft Visual C++ build tools(在下面的答案中提供)。版本14.0
在admin命令提示符中写下这些代码:
npm install --global --production windows-build-tools
然后按回车键。
您需要Microsoft Visual C ++构建工具,它们与Visual Studio一起打包。但是,它们现在也可以作为standalone download使用。安装这些工具并重新启动计算机后,您应该能够安装使用node-gyp的软件包。
Windows在管理工具中打开PowerShell并运行此命令
npm install --global --production windows-build-tools
我创造了一个issue on github for node-gyp。还有here is a disscussion的类似问题。 Probaly它没有帮助我,但它可能对其他人有用。
以上是关于在Windows中使用NPM和node-gyp进行故障排除的主要内容,如果未能解决你的问题,请参考以下文章
需要 node-gyp 的 npm install 在 Windows 上失败