[Node.js]npm安裝node-gyp

王嬌發表於2019-02-16

在Windows 10安裝過程中遇到了很多錯,試了一些方法記錄一下。

1. 需要安裝的模組

Microsoft .net framework
配置環境變數C:WindowsMicrosoft.NETFrameworkv4.0.30319
Visual Studio 2015
Windows SDK 8.1

2. 錯誤解決

報錯,

error MSB4019: The imported project “C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V110Microsoft.Cpp.Default.props” was not f
ound. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

解決辦法:電腦中Microsoft.Cpp.Default.props是在C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140目錄下,所以在以管理員身份開啟命令列,執行

SET VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140

然後報錯,應該是沒有安裝C++ compiler,

TRACKER : error TRK0005: Failed to locate: “CL.exe”. The system cannot find the file specified. [C:Usersjwang899Down
loadsEPM ProjectEPM-Webnode_modulesbufferutilbuildbufferutil.vcxproj]

解決辦法:在Visual Studio 2015中新建C++ project,這樣就會安裝C++ compiler。
然後再

npm install

報錯,

error MSB4019: The imported project “C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V110Microsoft.Cpp.Default.props” was not f
ound. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

再執行一次,

SET VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140

現在就可以了。

相關文章