【问题标题】:Nuxtjs site deploy fails in Netlify when using sass/scss + fibers使用 sass/scss + 纤维时,Nuxtjs 站点部署在 Netlify 中失败
【发布时间】:2021-12-09 19:13:36
【问题描述】:

每当我包含任何 SCSS 时,Netlify 上的部署都会失败。如果我取出 SCSS,它会很好地部署。它在本地运行良好。

您可以通过在此处拉取 repo https://github.com/jackcunningham/sasstest 轻松地重新创建它 或使用新的 nuxt 安装: javascriptnpm,无框架,pwa,无 linting 或测试,ssrstaticjsconfig.jsongit

根据此处的 nuxt 文档https://nuxtjs.org/docs/configuration-glossary/configuration-css/

,从那里安装带有纤维的 sass

#npm install --save-dev sass sass-loader@10 fibers

你可以通过在 pages/index.vue 的底部添加一个 scss 块来测试

<style lang="scss" scoped>
.home {
  h1 {
    color: yellow;
  }
}
</style>

这在本地运行良好,我也可以npm run buildgenerate

但在使用 npm run generate 的 Netlify 上却失败了

2:42:19 PM: ────────────────────────────────────────────────────────────────
2:42:19 PM:   "build.command" failed                                        
2:42:19 PM: ────────────────────────────────────────────────────────────────
2:42:19 PM: ​
2:42:19 PM:   Error message
2:42:19 PM:   Command failed with exit code 134: npm run generate
2:42:19 PM: ​
2:42:19 PM:   Error location
2:42:19 PM:   In Build command from Netlify app:
2:42:19 PM:   npm run generate
2:42:19 PM: ​
2:42:19 PM:   Resolved config
2:42:19 PM:   build:
2:42:19 PM:     command: npm run generate
2:42:19 PM:     commandOrigin: ui
2:42:19 PM:     publish: /opt/build/repo/dist
2:42:19 PM:     publishOrigin: ui
2:42:20 PM: Caching artifacts
...
2:42:20 PM: Finished saving go dependencies
2:42:20 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:42:20 PM: Creating deploy upload records
2:42:20 PM: Failing build: Failed to build site
2:42:20 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
2:42:20 PM: Finished processing build request in 34.120681685s

已更新: 我的依赖项如下所示,我已尝试降级包和节点版本以匹配以前工作正常但没有效果的项目,所以认为这是一个红鲱鱼,但在这里他们是

  "dependencies": {
    "@nuxtjs/pwa": "^3.3.5",
    "core-js": "3.8.3" //downgraded from "^3.15.1",
    "nuxt": "2.14.12" //downgraded from "^2.15.7"
  },
  "devDependencies": {
    "fibers": "^5.0.0",
    "sass": "1.36.0" //downgraded from "^1.43.3",
    "sass-loader": "10.1.1" //downgraded form "^10.2.0"
  }

我还添加了以下内容以强制节点版本匹配@kissu 版本(请参阅 cmets),但认为这不是问题

"engines": {
    "node": ">=14.15.0 <14.18.1"
  }

【问题讨论】:

标签: sass nuxt.js netlify fibers


【解决方案1】:

Node最新的LTS是14.18.1,Netlify至少支持v12
我在拥有v14.15.0 时下载了your project,当我在package.json 中删除您的engines 时,它工作得很好。

如果我使用您的特定版本 12.18.0 的 Node 安装项目,它仍然可以正常工作 when hosted on Netlifyengines 不变)。

另外,我不确定你为什么要使用超级特定版本的 Node,也许可以在这里给出一个范围:https://itnext.io/node-engines-helping-developers-everywhere-avoid-phantom-bugs-2eef519604b2

TLDR:到目前为止,我这边一切正常。问题可能出在其他地方。

【讨论】:

  • 谢谢,完全被难住了,甚至尝试了不同的 Netlify 帐户,我得到了相同的错误,一旦我更改 scss > css 就会修复。目前正在剥离我所有的 scss,以便我可以推进我的项目
猜你喜欢
  • 2021-09-10
  • 2021-10-27
  • 2019-11-14
  • 1970-01-01
  • 1970-01-01
  • 2021-08-11
  • 2022-09-09
  • 2022-01-23
相关资源
最近更新 更多