Sass-loader要求node-sass> = 4(即使存在)

我执行了对angular 6的更新。在ng serve -o期间,我收到sass-loader期望node-sass的错误。运行ng serve -o之后,我收到:

ERROR in ./src/sass/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/sass/styles.scss)
    Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/app.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)
ERROR in x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (loader.js:31:19)
ERROR in .x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)

显然,我检查了所有内容(我认为),但不知道发生了什么。

Package.Json:

"devDependencies": {
"@angular-devkit/build-angular": "~0.6.0",
"@angular/cli": "6.0.0",
"@angular/compiler-cli": "6.0.0",
"@angular/language-service": "6.0.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.106",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-html-detailed-reporter": "^1.1.21",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-teamcity-reporter": "^1.1.0",
"phantomjs-prebuilt": "^2.1.16",
"protractor": "~5.1.2",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.1",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "2.7.2"
}

dir -l node_modules说:

...
05/07/2018  08:53 AM    <DIR>          node-sass
...
05/07/2018  08:53 AM    <DIR>          sass-loader
...

我执行了:

npm rebuild node-sass 

第二方法:我删除了本地节点模块以及%User%\ AppData \ Roaming \ npm-cache。然后我删除了锁定文件并执行了npm

npm cache clear --force
npm install

但是仍然没有成功。

我想念什么?

米亚2020/03/24 19:12:01

以下步骤解决了这个问题

  1. 删除node-saas文件夹\Users\<user_id>\AppData\Roaming\npm-cache
  2. 删除node-saas文件夹<application_folder>/node_modules
  3. npm install运行<application_folder>
番长猴子2020/03/24 19:12:01

我使用以下步骤解决了此问题:

  1. 打开 package.json
  2. 添加您要安装的版本node-sass,例如"node-sass": "^4.12.0"
  3. 在命令行界面(CLI)中运行安装命令: npm install node-sass
  4. 该问题将得到解决。
十三蛋蛋2020/03/24 19:12:01
npm rebuild --force

阿斯洛帮助

米亚2020/03/24 19:12:01

我有以下问题,可以通过以下步骤解决:

  1. 删除package-lock.json文件。
  2. 转到node_module文件夹并运行rm -rf node_modules
  3. npm install

package-lock.json文件将使用新的依赖项版本自动更新。

希望能帮助到你。

GO2020/03/24 19:12:01

只需运行此代码...

npm install --save node-sass
2020/03/24 19:12:01

要解决您的问题,请运行以下命令

npm install --unsafe-perm

伽罗理查德2020/03/24 19:12:01

我用

npm install node-sass

在项目文件夹中,对于项目而言,因为在全局安装(带有-g选项)无法解决问题。

希望能帮助到你。