Mar*_*ius 33 node.js reactjs node-sass
执行此操作时,yarn install我收到此错误,但其他项目没有问题,也使用 Brew 安装节点。请注意我还应该尝试什么,有什么建议吗?
error */node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: */node_modules/node-sass
Output:
Building: /opt/homebrew/Cellar/node@14/14.18.1/bin/node */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 [
gyp verb cli '/opt/homebrew/Cellar/node@14/14.18.1/bin/node',
gyp verb cli '*/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 verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.18.1 | darwin | arm64
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 "/opt/homebrew/opt/python@3.9/bin/python3" in the PATH
gyp verb `which` succeeded /opt/homebrew/opt/python@3.9/bin/python3 /opt/homebrew/opt/python@3.9/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /opt/homebrew/opt/python@3.9/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:383:12)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at maybeClose (internal/child_process.js:1058:16)
gyp ERR! stack at Socket.<anonymous> (internal/child_process.js:443:11)
gyp ERR! stack at Socket.emit (events.js:400:28)
gyp ERR! stack at Pipe.<anonymous> (net.js:686:12)
gyp ERR! System Darwin 21.1.0
gyp ERR! command "/opt/homebrew/Cellar/node@14/14.18.1/bin/node" "*/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd */node_modules/node-sass
gyp ERR! node -v v14.18.1
Run Code Online (Sandbox Code Playgroud)
Mar*_*ius 18
通过根据我的 Node 安装将 node-sass 版本升级到正确的版本来修复,如下所示:https: //npmjs.com/package/node-sass
小智 9
错误原因是用Python3执行Python2程序。Python2 和 Python3的语法print不同。
print 'some text' # python 2.x
print('some text') # python 3
Run Code Online (Sandbox Code Playgroud)
也就是说依赖的node-gyp包node-sass还是用Python2编写的。
解决方案很简单:
.npmrc或.yarnrc。关于第二点,以macOS为例:
$ which python
/Users/frankie/.pyenv/shims/python
$ npm config set python /Users/frankie/.pyenv/shims/python
Run Code Online (Sandbox Code Playgroud)
小智 8
将MacOS更新到Monterey后,出现了这个问题。只需重新安装并重新链接节点版本,一切就修复了。
将版本更改为node@14并修复它。我做了什么:
brew install node@14
brew unlink node
brew link --overwrite node@14
Run Code Online (Sandbox Code Playgroud)
这是一篇文章,其中包含我使用过的命令https://medium.com/@georgeenathomas/3-step-process-to-downgrade-node-version-using-homebrew-bc0b0a72ae27
我在构建 Vue.js 并向其中添加 Buefy 时遇到此错误:
File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
Run Code Online (Sandbox Code Playgroud)
就我而言,问题似乎是 的node版本node-sass与package.json.
所以解决办法就是找到一个node-sass与你机器上安装的node版本兼容的版本。
由于我正在开发一个新项目来修复我可以简单地更新我的node最新版本,然后使用node-sass与其兼容的版本。检查此列表以了解兼容的内容
就我而言,我做了以下操作
1 | 我将 NODE 更新到最新版本(在我的例子中是 v16)
npm cache clean -f
npm install -g n
n stable
Run Code Online (Sandbox Code Playgroud)
2 | 我将node-sasspackage.json 中的版本更改为与节点 v16 兼容的版本"node-sass": "~6.0",
现在,如果我运行yarn install它就像一个魅力
| 归档时间: |
|
| 查看次数: |
48560 次 |
| 最近记录: |