yarn之后报node-sass错误

今天项目yarn以后报了以下错误:

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
error D:\workproject\wxapp-liuliangphone\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: D:\workproject\wxapp-liuliangphone\node_modules\node-sass
Output:
Building: D:\nodejs\node.exe D:\workproject\wxapp-liuliangphone\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsa
ss_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'D:\\nodejs\\node.exe',
gyp verb cli 'D:\\workproject\\wxapp-liuliangphone\\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@8.6.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/dist
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:\workproject\wxapp-liuliangphone\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (D:\\workproject\\wxapp-liuliangphone\\node_modules\\whic
h\\which.js:13:12)\n at F (D:\\workproject\\wxapp-liuliangphone\\node_modules\\which\\which.js:68:19)\n at E (D:\\workproject\\wxapp-liu
liangphone\\node_modules\\which\\which.js:80:29)\n at D:\\workproject\\wxapp-liuliangphone\\node_modules\\which\\which.js:89:16\n at D:\
\workproject\\wxapp-liuliangphone\\node_modules\\isexe\\index.js:42:5\n at D:\\workproject\\wxapp-liuliangphone\\node_modules\\isexe\\windo
ws.js:36:5\n at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed python { Error: not found: python
gyp verb `which` failed at getNotFoundError (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\workproject\wxapp-liuliangphone\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed stack: 'Error: not found: python\n at getNotFoundError (D:\\workproject\\wxapp-liuliangphone\\node_modules\\which
\\which.js:13:12)\n at F (D:\\workproject\\wxapp-liuliangphone\\node_modules\\which\\which.js:68:19)\n at E (D:\\workproject\\wxapp-liul
iangphone\\node_modules\\which\\which.js:80:29)\n at D:\\workproject\\wxapp-liuliangphone\\node_modules\\which\\which.js:89:16\n at D:\\
workproject\\wxapp-liuliangphone\\node_modules\\isexe\\index.js:42:5\n at D:\\workproject\\wxapp-liuliangphone\\node_modules\\isexe\\window
s.js:36:5\n at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". 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 "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (D:\workproject\wxapp-liuliangphone\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (D:\workproject\wxapp-liuliangphone\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (D:\workproject\wxapp-liuliangphone\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "D:\\nodejs\\node.exe" "D:\\workproject\\wxapp-liuliangphone\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose"
"--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\workproject\wxapp-liuliangphone\node_modules\node-sass
gyp ERR! node -v v8.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

网上找了一圈解决办法,大多是重装node-sass,大家可以试一下,但是我并没有用,依旧是ERR!,因为产生的原因是因为windows缺少编译的运行环境所以无法安装node-sass导致的错误,只需要:

1
yarn global add node-gyp  windows-build-tools

安装完windows-build-tools以后重新yarn就可以了,亲测有效