【问题标题】:React modules installation failsReact 模块安装失败
【发布时间】:2018-08-13 12:59:04
【问题描述】:

我正在尝试通过 yarnnpm 安装 sass-loadernode-sass,但遇到相同的错误。

我尝试使用其中一种:

yarn add sass-loader@6.0.6 node-sass@4.5.3
npm install sass-loader@6.0.6 node-sass@4.5.3

但两者都会产生类似的错误。这是纱线的回应:

编辑:我正在使用 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 个小时,希望能得到一些帮助。

可能是一些权限的东西吗?我不明白为什么会发生这种情况,因为我只是一步一步地遵循基本教程。

【问题讨论】:

  • 是的,我是@HyyanAboFakher
  • 找不到 Python 可执行文件“python”,你可以设置 PYT HON 环境变量。你应该安装 python 和 put 路径到 bin文件夹到 PATH 变量。
  • 为什么版本需要具体?我很确定安装这两者的最新版本可以解决这个问题。
  • @Yossi 查看我分享的链接以将 Python 添加到您的路径

标签: javascript reactjs npm yarnpkg


【解决方案1】:

node-gyp 在 Windows 上构建失败是很常见的情况。 要使构建通过,请按照official documentation中描述的步骤进行操作

完成这项工作的最简单方法是使用npmyarn 安装windows-build-tools

npm install --global --production windows-build-tools

然后再次尝试安装node-sasssass-loader

使用Bash on Ubuntu on windows也可以解决问题

【讨论】:

  • 我会请求权限并报告状态。感谢您的帮助。
  • 抱歉耽搁了。显然是权限问题,特定端口被阻止或 w/e ,这就是为什么有些下载有效而有些没有。我们已经添加了所需的权限。感谢您的帮助,点赞:)
【解决方案2】:

我认为错误清楚地表明 python 没有添加到您的环境变量中,或者它甚至没有安装在系统上。请解决python依赖并重试。

gyp verb check python checking for Python executable "python2" in the PATH

【讨论】:

  • 你能检查一下它是否在你的环境变量中吗?
猜你喜欢
  • 2018-06-19
  • 2013-11-04
  • 2020-06-19
  • 1970-01-01
  • 1970-01-01
  • 2022-12-03
  • 1970-01-01
  • 2013-11-05
  • 2020-05-18
相关资源
最近更新 更多