本文介绍了**node-sass:命令失败**当rails新app_Path时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个新的Rails应用程序,安装了以下版本:

节点v15.6.0

NPM v7.4.0

纱线v1.22.10

Ruby 3.0.0

Rails 6.0.3.4

当我运行rails new app_Path时,进入纱线安装时出错,如下所示:

yarn add v1.22.10
warning ../package.json: No license field
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning @rails/webpacker > node-sass > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > node-gyp > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > request > [email protected]: this library is no longer supported
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > [email protected]: https://github.com/lydell/resolve-url#deprecated
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > [email protected]: Please see https://github.com/lydell/urix#deprecated
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[1/3] ⠈ fsevents
[-/3] ⠈ waiting...
error /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass
Output:
Building: /usr/local/bin/node /Users/Lorenzo/code/LorenzoXavier/webpacker_js/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   '/usr/local/bin/node',
gyp verb cli   '/Users/Lorenzo/code/LorenzoXavier/webpacker_js/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 [email protected]
gyp info using [email protected] | darwin | 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 "/usr/bin/python" in the PATH
gyp verb `which` succeeded /usr/bin/python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import sys; print "2.7.16
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 version: 15.6.0
gyp verb command install [ '15.6.0' ]
gyp verb install input version string "15.6.0"
gyp verb install installing version: 15.6.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 15.6.0
gyp verb build dir attempting to create "build" dir: /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/build
gyp verb build dir "build" dir needed to be created? /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/config.gypi
gyp verb common.gypi checking for gypi file: /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args   '/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Lorenzo/.node-gyp/15.6.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/Lorenzo/.node-gyp/15.6.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/Lorenzo/.node-gyp/15.6.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (node:events:379:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:285:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/bin/node" "/Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/Lorenzo/code/LorenzoXavier/webpacker_js/node_modules/node-sass
gyp ERR! node -v v15.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

错误似乎发生在节点Sass

有没有人有这个问题?

我也在尝试更新Mac上的node-gyp,但我没有运气。我已尝试$npm install-g node-gyp,但每次运行rails new时仍显示node-gyp -v v3.8.0

推荐答案

尝试更新您的WebPacker版本。

我的repo指定了WebPacker v4.3.0,它将node-sass作为依赖项包括在内,但Node v16不支持它。

我的Package.json中还单独包含了node-sass,我相信它可以安全地替换为sass。

这篇关于**node-sass:命令失败**当rails新app_Path时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 06:49