这两天学习Laravel,管理及编译前端代码的时候用到了elixir,但在windows下,
npm(cnpm) install
的时候报错,大概意思是需要编译,而编译依赖于VC++
和python 2.7
。网上的解决方案大多为配置VS
以及Python 2.7
环境,但不想额外配置环境,终于找到一个无需编译的解决方案,此处mark。
错误描述
使用gulp
命令时报错如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21[20:02:53] Using gulpfile D:\XXX\Dev\gulpfile.js
[20:02:53] Starting 'default'...
[20:02:53] Starting 'sass'...
[20:02:53] 'sass' errored after 83 ms
[20:02:53] Error: The `libsass` binding was not found in D:\XXX\Dev\node_mod
This usually happens because your node version has changed.
Run `npm rebuild node-sass` to build the binding for your current node version.
at Object.sass.getBinaryPath (D:\XXX\Dev\node_modules\.npminstall\node-s
at Object.<anonymous> (D:\XXX\Dev\node_modules\.npminstall\node-sass\3.4
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\XXX\Dev\node_modules\.npminstall\gulp-sass\2.2
at Module._compile (module.js:409:26)
[20:02:53] Error in plugin 'run-sequence'
Message:
An error occured in task 'sass'.
[20:02:53] Finished 'default' after 121 ms
因此需要重新编译,执行命令1
2# 使用cnpm(墙内)
npm rebuild node-sass
而又报错如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env
gyp ERR! stack at failNoPython (D:\XXX\Dev\node_modules\.npminstall\node
gyp ERR! stack at D:\XXX\Dev\node_modules\.npminstall\node-gyp\3.3.1\nod
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\XXX\\Dev\\node_m
erbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\XXX\Dev\node_modules\laravel-elixir\node_modules\gulp-sass\n
gyp ERR! node -v v4.4.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
Build failed
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Administrator\\AppData\\
fig=C:\\Users\\Administrator\\.cnpmrc" "--disturl=https://npm.taobao.org/mirrors/node" "
npm ERR! node v4.4.1
npm ERR! npm v3.8.3
npm ERR! code ELIFECYCLE
npm ERR! node-sass@3.4.2 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.4.2 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! D:\XXX\Dev\npm-debug.log
提示编译需要Python
环境。
解决方案
在cnodejs论坛上发现了一个类似的帖子,在回复的最后发现了一个答案,即先安装bcryptjs
,则可不需要编译。
测试通过!
附上cnpm上的链接1
http://npm.taobao.org/package/bcryptjs