我正在尝试同时通过sass-loader
和node-sass
安装yarn
和npm
,但是得到相同的错误。
我尝试使用其中之一:
yarn add sass-loader@6.0.6 node-sass@4.5.3
npm install sass-loader@6.0.6 node-sass@4.5.3
但是两者都会产生相似的错误。这是来自yarn的响应:
编辑:我正在使用Windows。设置python的路径后,这是我得到的响应:
[3/4] Linking dependencies...
warning " > react-modal@2.2.2" has incorrect peer dependency "react@^0.14.0 || ^
15.0.0".
warning " > react-modal@2.2.2" has incorrect peer dependency "react-dom@^0.14.0
|| ^15.0.0".
[4/4] Building fresh packages...
[-/2] ? waiting...
error C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\node-sass
: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\node
-sass
Output:
Building: C:\Program Files\nodejs\node.exe C:\Users\sagil\Desktop\ReactTutorial\
indecision-app\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\\nodejs\\node.exe',
gyp verb cli 'C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_m
odules\\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.7.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 (C:\Users\sagil\Desktop\ReactTut
orial\indecision-app\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:158:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\sagil\Desktop\ReactTut
orial\indecision-app\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:158:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2\n at getNotFoundError (
C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_modules\\which\\w
hich.js:13:12)\n at F (C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-a
pp\\node_modules\\which\\which.js:68:19)\n at E (C:\\Users\\sagil\\Desktop\\R
eactTutorial\\indecision-app\\node_modules\\which\\which.js:80:29)\n at C:\\U
sers\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_modules\\which\\which.
js:89:16\n at C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_
modules\\isexe\\index.js:42:5\n at C:\\Users\\sagil\\Desktop\\ReactTutorial\\
indecision-app\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplet
e (fs.js:158:21)',
gyp verb `which` failed 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 sys; print "2.7
.13
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node v
ersion: 10.7.0
gyp verb command install [ '10.7.0' ]
gyp verb install input version string "10.7.0"
gyp verb install installing version: 10.7.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 10.7.0
gyp verb ensuring nodedir is created C:\Users\sagil\.node-gyp\10.7.0
gyp verb created nodedir C:\Users\sagil\.node-gyp\10.7.0
gyp http GET https://nodejs.org/download/release/v10.7.0/node-v10.7.0-headers.ta
r.gz
gyp WARN install got an error, rolling back install
gyp verb command remove [ '10.7.0' ]
gyp verb remove using node-gyp dir: C:\Users\sagil\.node-gyp
gyp verb remove removing target version: 10.7.0
gyp verb remove removing development files for version: 10.7.0
gyp ERR! configure error
gyp ERR! stack Error: connect ETIMEDOUT 104.20.22.46:443
gyp ERR! stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1163:1
4)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\sagil\\Deskto
p\\ReactTutorial\\indecision-app\\node_modules\\node-gyp\\bin\\node-gyp.js" "reb
uild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--l
ibsass_library="
gyp ERR! cwd C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\no
de-sass
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this comm
我已尝试按照错误之一所述下载python 2.7。但是错误仍然相同。我在此上停留了3个小时,不胜感激。
可能是一些权限的东西吗?我不明白为什么会这样,因为我只是一步一步地按照基本的教程进行操作。
答案 0 :(得分:1)
在Windows上node-gyp
构建失败是很常见的情况。
要通过构建,请按照official documentation
最简单的方法是使用npm
或yarn
来安装windows-build-tools
npm install --global --production windows-build-tools
然后再次尝试安装node-sass
和sass-loader
答案 1 :(得分:0)
我认为该错误明确指出python没有添加到您的环境变量中,或者甚至没有安装在系统上。请解决python依赖项,然后重试。
gyp verb check python checking for Python executable "python2" in the PATH