前言:
今天一公司某位同学突然需要启动一个很久以前的项目(其实也没多久,只是好久没有这个项目的新需求,所以就尘封了,项目还在运行的)
启动报错了~~
Node Sass could not find a binding for your current environment: Windows 32-bit with Node.js 10.x
这行报错,据我目测这位同学是升级了node到10.x版本然后node-sass不支持。
情况的确是这个情况,之前是使用node8.11.3前一段时间换成了10.15.3
重新安装一下依赖吧
然后我惊呆了
error D:\work\m.dongdao\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: D:\work\m.dongdao\node_modules\node-sass
Output:
Building: C:\Program Files (x86)\nodejs\node.exe D:\work\m.dongdao\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 [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
gyp verb cli 'D:\\work\\m.dongdao\\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.8.0
gyp info using node@10.15.3 | win32 | ia32
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.7" in the PATH
gyp verb `which` failed Error: not found: python2.7
gyp verb `which` failed at getNotFoundError (D:\work\m.dongdao\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\work\m.dongdao\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\work\m.dongdao\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\work\m.dongdao\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\work\m.dongdao\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\work\m.dongdao\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed python2.7 { Error: not found: python2.7
gyp verb `which` failed at getNotFoundError (D:\work\m.dongdao\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\work\m.dongdao\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\work\m.dongdao\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\work\m.dongdao\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\work\m.dongdao\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\work\m.dongdao\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2.7\n at getNotFoundError (D:\\work\\m.dongdao\\node_modules\\which\\which.js:13:12)\n at F (D:\\work\\m.dongdao\\node_modules\\which\\which.js:68:19)\n at E (D:\\work\\m.dongdao\\node_modules\\which\\which.js:80:29)\n at D:\\work\\m.dongdao\\node_modules\\which\\which.js:89:16\n at D:\\work\\m.dongdao\\node_modules\\isexe\\index.js:42:5\n at D:\\work\\m.dongdao\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb could not find "python2.7". checking python launcher
gyp verb could not find "python2.7". 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 "python2.7", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (D:\work\m.dongdao\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (D:\work\m.dongdao\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (D:\work\m.dongdao\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "D:\\work\\m.dongdao\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\work\m.dongdao\node_modules\node-sass
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
我觉得我需要认真对待了
从报错信息上看
(1)这次安装过程中python2.7没找到
(2)错误都是gyp开头,node-gyp是跨平台调用的node插件,比如可以调用python,c++等
(3)这两个错误导致node-sass安装失败
看起来只要把python2.7安装就可以了
npm install --global --production windows-build-tools
这个包会在电脑上安装三个语言支持
1、python(v2.7 ,3.x不支持);
2、visual C++ Build Tools,或者 (vs2015以上(包含15))
3、.net framework 4.5.1
静静等待····················
静静等待····················
静静等待····················