./src/styles.scss中的错误。模块构建失败:错误:找不到模块“ node-sass”

时间:2018-08-14 21:35:07

标签: node.js npm npm-install

当我尝试在新计算机上执行npm start时,出现以下错误:

    Time: 18322ms
chunk {main} main.js, main.js.map (main) 487 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 430 kB  [rendered]
chunk {styles} styles.js, styles.js.map (styles) 282 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.32 MB [initial] [rendered]

ERROR in ./src/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed: Error: Cannot find module 'node-sass'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.sassLoader (C:\...(path)...\node_modules\sass-loader\lib\loader.js:24:22)
i 「wdm」: Failed to compile.

我的Angular.json

...
 "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.css",
              "node_modules/font-awesome/css/font-awesome.css",
              "node_modules/animate.css/animate.min.css",
              "src/styles.scss",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/alertify.js/dist/css/alertify.css"
            ],
...

我的节点版本: v8.11.3 角度5 +

3 个答案:

答案 0 :(得分:2)

错误提示为Error: Cannot find module 'node-sass'。为了解决这个问题,您必须使用以下命令安装node-sass:

npm install node-sass

答案 1 :(得分:1)

根据错误, node-sass 不存在或未正确安装。

您必须使用以下命令进行安装

npm install node-sass

npm install --save node-sass

答案 2 :(得分:1)

不推荐使用 node-sass 库。使用 sass 代替:

npm install sass