【问题标题】:Node-sass not compiling on AzureNode-sass 未在 Azure 上编译
【发布时间】:2019-11-24 20:57:44
【问题描述】:

我已将我的 React 应用程序部署到 Azure 上,目前在加载网站时出现此编译错误:

./src/components/LoadingScreen/LoadingScreen.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/components/LoadingScreen/LoadingScreen.scss)
Error: Missing binding /home/site/wwwroot/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x

Found bindings for the following environments:
  - Windows 64-bit with Node.js 10.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.

我尝试在几个地方运行npm rebuild node-sass,但到目前为止都没有运气。发生这种情况是因为它是用 Windows 构建但部署到 Linux 机器上的吗?我该如何解决这个问题?

【问题讨论】:

  • 删除node_modules下的node-sass文件夹然后执行npm install
  • 酷,我把它作为答案,请接受它是正确的

标签: reactjs azure node-modules node-sass


【解决方案1】:

只需删除node_modules下的node-sass文件夹,然后执行npm install

【讨论】:

    【解决方案2】:

    如果注释的答案不起作用,您也可以尝试在生产中构建后运行 npm rebuild node-sass。如果 node-sass 安装在单独的操作系统环境(即 windows/linux)中,我相信这个错误会发生在 Docker 容器中。所以你可以运行npm run start npm rebuild node-sass,让它在正确的环境中重建。

    如果您确实删除并重建,那么在开发之前在您的 prod 环境中运行 npm install 可能也很有用。

    【讨论】:

      猜你喜欢
      • 2020-12-09
      • 2015-02-17
      • 2021-11-08
      • 2020-10-11
      • 2018-07-17
      • 2013-03-18
      • 1970-01-01
      • 2020-05-14
      • 2021-05-21
      相关资源
      最近更新 更多