Node-sass无法在Azure上编译

我已将我的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机器上?我该如何解决?

CHGXING 回答:Node-sass无法在Azure上编译

如果注释不起作用,您还可以尝试在生产中进行构建后运行npm rebuild node-sass。我相信,如果将node-sass安装在单独的OS环境(即Windows / Linux)中,则会在Docker容器中发生此错误。因此,您可以运行npm run start npm rebuild node-sass,以便在正确的环境中重建它。

如果确实要删除和重建,则在开发之前在产品环境中运行npm安装可能也很有用。

,

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

本文链接:https://www.f2er.com/3040153.html

大家都在问