今天通過npm 安裝 install 的時候出現的問題


E:\Workspace_WebStorm\angular2>npm install -g
C:\Users\lyx\AppData\Roaming\npm
`-- angular2@0.0.0
`-- UNMET PEER DEPENDENCY typescript@>=1.8.0 <2.1.0 || >=1.9.0-dev || >=2.0.0-dev || || >=2.1.0-dev

npm WARN ts-helpers@1.1.2 requires a peer of typescript@>=1.8.0 <2.1.0 || >=1.9.0-dev || >=2.0.0-dev || || >=2.1.0-dev but none was installed.

E:\Workspace_WebStorm\angular2>npm install
npm WARN deprecated angular-cli@1.0.0-beta.28.3: angular-cli has been renamed to @angular/cli. Please update your dependencies.

> node-sass@4.5.0 install E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.0/win32-x64-51_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.0/win32-x64-51_binding.node":

ESOCKETTIMEDOUT

Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.

export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

npm config set proxy http://example.com:8080

> node-sass@4.5.0 postinstall E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass
> node scripts/build.js

Binary found at E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\vendor\win32-x64-51\binding.node
Testing binary
Binary has a problem: Error: %1 is not a valid Win32 application.
\\?\E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\vendor\win32-x64-51\binding.node
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at module.exports (E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\lib\binding.js:19:10)
at Object.<anonymous> (E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
Building the binary locally
Building: E:\node\node.exe E:\Workspace_WebStorm\angular2\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'E:\\node\\node.exe',
gyp verb cli 'E:\\Workspace_WebStorm\\angular2\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp@3.5.0
gyp info using node@7.5.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\isexe\index.js:44:5
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\isexe\windows.js:29:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:112:15)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\Workspace_WebStorm\angular2\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\isexe\index.js:44:5
gyp verb `which` failed at E:\Workspace_WebStorm\angular2\node_modules\isexe\windows.js:29:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:112:15) code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Python27\python.EXE
gyp verb check python version `C:\Python27\python.EXE -c "import platform; print(platform.python_version());"` returned: "2.7.13\r\n"
gyp verb get node dir no --target version specified, falling back to host node version: 7.5.0
gyp verb command install [ '7.5.0' ]
gyp verb install input version string "7.5.0"
gyp verb install installing version: 7.5.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 7.5.0
gyp verb build dir attempting to create "build" dir: E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build
gyp verb build dir "build" dir needed to be created? E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build\config.gypi
gyp verb config.gypi checking for gypi file: E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\config.gypi
gyp verb common.gypi checking for gypi file: E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'E:\\Workspace_WebStorm\\angular2\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=auto',
gyp info spawn args '-I',
gyp info spawn args 'E:\\Workspace_WebStorm\\angular2\\node_modules\\angular-cli\\node_modules\\node-sass\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'E:\\Workspace_WebStorm\\angular2\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\lyx\\.node-gyp\\7.5.0\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\lyx\\.node-gyp\\7.5.0',
gyp info spawn args '-Dnode_gyp_dir=E:\\Workspace_WebStorm\\angular2\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=E:\\Workspace_WebStorm\\angular2\\node_modules\\angular-cli\\node_modules\\node-sass',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'E:\\Workspace_WebStorm\\angular2\\node_modules\\angular-cli\\node_modules\\node-sass\\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir C:\Users\lyx\.node-gyp\7.5.0
gyp verb found first Solution file build/binding.sln
gyp verb could not find "msbuild.exe" in PATH - finding location in registry
gyp verb "Release" dir needed to be created? null
gyp verb copying "node.lib" for x64 C:\Users\lyx\.node-gyp\7.5.0\Release\node.lib
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
在此解決方案中一次生成一個項目。若要啟用並行生成,請添加“/m”開關。
生成啟動時間為 2017/2/26 16:01:32。
節點 1 上的項目“E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build\binding.sln”(默認目標)。
ValidateSolutionConfiguration:
正在生成解決方案配置“Release|x64”。
MSBUILD : error MSB3428: 未能加載 Visual C++ 組件“VCBuild.exe”。要解決此問題,1) 安裝 .NET Framework 2.0 SDK;2) 安裝 Microsoft Visual Stu
dio 2005;或 3) 如果將該組件安裝到了其他位置,請將其位置添加到系統路徑中。 [E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-
sass\build\binding.sln]
已完成生成項目“E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build\binding.sln”(默認 目標)的操作 - 失敗


生成失敗。

“E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass\build\binding.sln”(默認目標) (1) ->
(_src_\libsass 目標) ->
MSBUILD : error MSB3428: 未能加載 Visual C++ 組件“VCBuild.exe”。要解決此問題,1) 安裝 .NET Framework 2.0 SDK;2) 安 裝 Microsoft Visual S
tudio 2005;或 3) 如果將該組件安裝到了其他位置,請將其位置添加到系統路徑中。 [E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\nod
e-sass\build\binding.sln]

0 個警告
1 個錯誤

已用時間 00:00:00.57
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 (E:\Workspace_WebStorm\angular2\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:192:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "E:\\node\\node.exe" "E:\\Workspace_WebStorm\\angular2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\Workspace_WebStorm\angular2\node_modules\angular-cli\node_modules\node-sass
gyp ERR! node -v v7.5.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open 'E:\Workspace_WebStorm\angular2\node_modules\node-sass\package.json'
npm WARN sass-loader@4.1.1 requires a peer of node-sass@^3.4.2 || ^4.0.0 but none was installed.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "E:\\node\\node.exe" "E:\\node\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE

npm ERR! node-sass@4.5.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.5.0 postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! E:\Workspace_WebStorm\angular2\npm-debug.log

------------------------------------------------------------------------

生成啟動時間為 2016/6/27 星期一 11:39:46。
節點 1 上的項目“C:\Users\世民\node_modules\node-sass\build\binding.sln”(默認目標)。
ValidateSolutionConfiguration:
  正在生成解決方案配置“Release|x64”。
MSBUILD : error MSB3428: 未能加載 Visual C++ 組件“VCBuild.exe”。要解決此問題,1) 安裝 .NET Framework 2.0 SDK;2) 安裝 Microsoft Visual Studio 2005;或 3) 如果將該組件安裝到了其他位置,請將其位置添加到系統路徑
中。 [C:\Users\世民\node_modules\node-sass\build\bindi
ng.sln]
已完成生成項目“C:\Users\世民\node_modules\node-sass\build\binding.sln”(默認目標)的操作 - 失敗。


生成失敗。

“C:\Users\世民\node_modules\node-sass\build\binding.sln”(默認目標) (1) ->
(_src_\libsass 目標) ->
  MSBUILD : error MSB3428: 未能加載 Visual C++ 組件“VCBuild.exe”。要解決此問題,1) 安裝 .NET Framework 2.0 SDK;2) 安裝 Microsoft Visual Studio 2005;或 3) 如果將該組件安裝到了其他位置,請將其位置添加到系統路
徑中。 [C:\Users\世民\node_modules\node-sass\build\bin
ding.sln]

    0 個警告
    1 個錯誤

然后呢,就一頭賽到vc++組件里去,安裝各種無用的東西,嘗試過各種解決方案,最后實在是沒有辦法了,就仔細的從頭到尾的看錯誤信息,然后在 node scripts/install.js 之后發現這么一句話

Cannot download "https://github.com/sass/node-sass/releases/download/v3.8.0/win32-x64-46_binding.node":

這句話大家都懂的哈,我就不說了,這里我也不知道為什么會下載失敗,因為我的電腦全局代理的,正常的訪問任何網站都是無阻礙的,百思不得解,

好吧那我就自己下載吧(為什么自己下載?因為我在google的時候也是發現了寫有用的東西,雖然沒那么直觀哈,但是也給了我很多幫助)

下載完了之后把它注冊成全局環境變量,兩種方式:

第一種:直接右鍵我的電腦--》屬性--》高級系統設置--》環境變量--》添加

第二種:set XXX=文件路經--》set SASS_BINARY_PATH=F:\lishiming\tools\node-sass\win32-x64-46_binding.node

查看環境是否合適:echo %SASS_BINARY_PATH%

如果打印出來您配置好的文件地址那就ok了,

最后再來試試安裝:npm i -g node-sass

參照上面的答案完美解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM