node-sass安装报错

傅穆冉
2023-12-01

$ cnpm install node-sass --save-dev
√ Installed 1 packages
√ Linked 18 latest versions
node-sass build Binary found at D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass\vendor\win32-x64-48\binding.node
Binary found at D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass\vendor\win32-x64-48\binding.node
Testing binary
Binary has a problem: Error: %1 is not a valid Win32 application.
\\?\D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass\vendor\win32-x64-48\binding.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at module.exports (D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass\lib\binding.js:19:10)
at Object.<anonymous> (D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass\lib\index.js:14:35)
at Module._compile (module.js:570:32)
Building the binary locally
Building: C:\Program Files\nodejs\node.exe D:\n8\nweb\node_modules\_node-gyp@3.6.2@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 [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'D:\\n8\\nweb\\node_modules\\_node-gyp@3.6.2@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.6.2
gyp info using node@6.10.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb download using dist-url https://npm.taobao.org/mirrors/node
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 (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:13:12)
gyp verb `which` failed at F (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:68:19)
gyp verb `which` failed at E (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:80:29)
gyp verb `which` failed at D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:89:16
gyp verb `which` failed at D:\n8\nweb\node_modules\_isexe@2.0.0@isexe\index.js:42:5
gyp verb `which` failed at D:\n8\nweb\node_modules\_isexe@2.0.0@isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:13:12)
gyp verb `which` failed at F (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:68:19)
gyp verb `which` failed at E (D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:80:29)
gyp verb `which` failed at D:\n8\nweb\node_modules\_which@1.3.0@which\which.js:89:16
gyp verb `which` failed at D:\n8\nweb\node_modules\_isexe@2.0.0@isexe\index.js:42:5
gyp verb `which` failed at D:\n8\nweb\node_modules\_isexe@2.0.0@isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (D:\\n8\\nweb\\node_modules\\_which@1.3.0@which\\which.js:13:12)\n at F (D:\\n8\\nweb\\node_modules\\_which@1.3.0@which\\which.js:68:19)\n at E (D:\\n8\\nweb\\node_modules\\_which@1.3.0@which\\which.js:80:29)\n at D:\\n8\\nweb\\node_modules\\_which@1.3.0@which\\which.js:89:16\n at D:\\n8\\nweb\\node_modules\\_isexe@2.0.0@isexe\\index.js:42:5\n at D:\\n8\\nweb\\node_modules\\_isexe@2.0.0@isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\asus-1\AppData\Local\Programs\Python\Python36-32\python.EXE
gyp verb check python version `C:\Users\asus-1\AppData\Local\Programs\Python\Python36-32\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.2\r\n"
gyp verb could not find "C:\Users\asus-1\AppData\Local\Programs\Python\Python36-32\python.EXE". checking python launcher
gyp verb could not find "C:\Users\asus-1\AppData\Local\Programs\Python\Python36-32\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\asus-1\AppData\Local\Programs\Python\Python36-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at Object.failNoPython (D:\n8\nweb\node_modules\_node-gyp@3.6.2@node-gyp\lib\configure.js:483:19)
gyp ERR! stack at Object.<anonymous> (D:\n8\nweb\node_modules\_node-gyp@3.6.2@node-gyp\lib\configure.js:508:16)
gyp ERR! stack at D:\n8\nweb\node_modules\_graceful-fs@4.1.11@graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\n8\\nweb\\node_modules\\_node-gyp@3.6.2@node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\n8\nweb\node_modules\_node-sass@4.5.3@node-sass
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
× Install fail! Error: post install error, please remove node_modules before retry!
Run "C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1
Error: post install error, please remove node_modules before retry!
Run "C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1
at ChildProcess.proc.on.code (C:\Users\asus-1\AppData\Roaming\npm\node_modules\cnpm\node_modules\runscript\index.js:74:21)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npminstall version: 3.1.4
npminstall args: C:\Program Files\nodejs\node.exe C:\Users\asus-1\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\bin\install.js --china --userconfig=C:\Users\asus-1\.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=http://registry.npm.taobao.org node-sass --save-dev

 

 

解决方案:

https://github.com/sass/node-sass/releases

下载

win32-x64-48\binding.node文件

在项目文件夹的\node_modules\_node-sass@4.5.3@node-sass\vendor\win32-x64-48目录下,用下载的文件替换原来的文件

再npm i node-sass --save 即可。

*github issue上网友的方法是找到C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\版本号  文件夹,将下载的文件放进去,但我亲测无效。

 

最后说一句,真TM坑

转载于:https://www.cnblogs.com/alan2kat/p/7610766.html

 类似资料: