【问题标题】:Unable to precompile-assets无法预编译资产
【发布时间】:2021-05-07 07:11:48
【问题描述】:

我正在尝试预编译资产,但遇到了一个相当模糊的错误。我认为这可能是 node-sass 的问题,然后导致我尝试通过 Yarn 安装,但这也失败了,并出现了一个不太有用的错误。任何帮助将不胜感激。

预编译资产似乎在往南走:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/path/to/example.com/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Linux 2.6.32-042stab120.19
gyp ERR! command "/root/.nvm/versions/node/v15.3.0/bin/node" "/path/to/example.com/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /path/to/example.com/node_modules/node-sass
gyp ERR! node -v v15.3.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1

Full Output of: RAILS_ENV=production rails assets:precompile

通过 yarn 添加 node-sass 有类似的输出:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (path/to/example.com/node_modules/@rails/webpacker/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Linux 2.6.32-042stab120.19
gyp ERR! command "/root/.nvm/versions/node/v15.3.0/bin/node" "path/to/example.com/node_modules/@rails/webpacker/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd path/to/example.com/node_modules/@rails/webpacker/node_modules/node-sass
gyp ERR! node -v v15.3.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

Full Output of: yarn add node-sass

【问题讨论】:

  • 你试过运行npm rebuild吗?

标签: ruby-on-rails ruby yarnpkg node-sass


【解决方案1】:

您似乎正在尝试在 Node 15 上安装旧版本的 node-sass。Node 15 仅在 node-sass v5 https://github.com/sass/node-sass#node-version-support-policy 上受支持

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    相关资源
    最近更新 更多