npm install canvas安装报错node-gyp rebuild

C:UsersAdministratorDesktophotchcms-master>npm i canvas

canvas@1.6.6 install C:UsersAdministratorDesktophotchcms-masternode_modulescanvas
node-gyp rebuild

C:UsersAdministratorDesktophotchcms-masternode_modulescanvas>if not defined npm_config_node_gyp (node "C:Program Filesnodejsnode_module
snpmbinnode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild ) else (node "" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:Program Files (x86)MSBuildMicrosoft.Cppv4.0Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'canvas.
vcxproj' is invalid. Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and hav
e specified a non-default Platform that doesn't exist for this project. [C:UsersAdministratorDesktophotchcms-masternode_modulescanvasbui
ldcanvas.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-gyplibbuild.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.15063
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:UsersAdministratorDesktophotchcms-masternode_modulescanvas
gyp ERR! node -v v8.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN hotchcms@0.0.1 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.6 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.6.6 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataRoamingnpm-cache_logs2017-09-04T13_05_53_731Z-debug.log

阅读 11.2k
2 个回答

直接设置了下载来源cnpm,这样就不用编译了,解决了。

可能是网络原因导致的,可以将仓库设置为国内的淘宝源:

npm 全局安装路径

查看

npm root -g

设置

npm config set prefix '路径'

设置远程仓库为淘宝源

npm config set registry https://registry.npm.taobao.org 

验证是否设置成功

npm config get registry 

这样以后使用的时候,直接将 npm 命令替换为 cnpm

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题