【问题标题】:Trying to install npm node-sass尝试安装 npm node-sass
【发布时间】:2018-09-10 16:50:50
【问题描述】:

在任何版本尝试通过 npm 安装 node-sass 时都会出现错误。知道为什么吗?我试过了:

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

因此,当我尝试运行 'npm start' 时,我收到错误“找不到模块 '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"
          }  
        }

【问题讨论】:

  • 尝试错误中提到的完整日志
  • 试试sudo npm install... 可能是权限问题。
  • 也许这会有所帮助npm cache clean

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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    使用以下命令:

    sudo npm install --unsafe-perm node-sass
    

    【讨论】:

      【解决方案3】:

      写这些

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

      【讨论】:

        猜你喜欢
        • 2019-01-17
        • 1970-01-01
        • 2018-08-23
        • 2019-09-08
        • 2020-02-25
        • 2019-03-16
        • 2015-08-03
        • 2020-10-31
        • 2021-03-01
        相关资源
        最近更新 更多