试图安装npm node-sass

时间:2018-04-01 04:41:30

标签: reactjs npm webpack package.json node-sass

当试图通过npm在任何版本安装node-sass时,我收到错误。知道为什么吗?我试过了:

  • 将node-sass更新为最新版本
  • 将所有内容更新为更新版本并重新格式化webpack.config.js
  • 卸载/删除所有软件包并重新安装

enter image description here

因此,当我尝试运行'npm start'时,我收到错误" ERROR in找不到模块' node-sass'"

  [245] ./src/components/SkiDayCount.js 1.46 kB {0} [built]
  [246] ./src/stylesheets/ui.scss 1.17 kB {0} [built] [1 error]
  [248] ./~/style-loader/addStyles.js 7.15 kB {0} [built]

ERROR in Cannot find module 'node-sass'
 @ ./src/stylesheets/ui.scss 4:14-163
webpack: Failed to compile.

这是我的package.json。

 {
          "name": "",
          "version": "1.0.0",
          "description": "",
          "main": "index.js",
          "scripts": {
            "start": "./node_modules/.bin/webpack-dev-server"
          },
          "author": "",
          "license": "MIT",
          "devDependencies": {
            "autoprefixer-loader": "3.2.0",
            "babel-cli": "6.18.0",
            "babel-loader": "6.2.5",
            "babel-preset-latest": "6.16.0",
            "babel-preset-react": "6.16.0",
            "babel-preset-stage-0": "6.16.0",
            "css-loader": "0.25.0",
            "json-loader": "0.5.4",
            "node-sass": "3.10.1",
            "sass-loader": "4.0.2",
            "style-loader": "0.13.1",
            "webpack": "1.13.3",
            "webpack-dev-server": "1.16.2"
          },
          "dependencies": {
            "react": "15.3.2",
            "react-dom": "15.3.2"
          }  
        }

3 个答案:

答案 0 :(得分:0)

写这些

npm install style-loader css-loader autoprefixer-loader sass-loader node-sass  --save-dev

答案 1 :(得分:0)

使用以下命令:

sudo npm install --unsafe-perm node-sass

答案 2 :(得分:0)

我尝试过,它对我有用:sudo npm install --save-dev --unsafe-perm node-sass