Node Sass 版本 9.0.0 与 ^4.0.0 不兼容

问题描述 投票:0回答:1

我的应用程序中没有安装 node-sass 或 sass 包。但我一直收到这个错误

ERROR in ./src/scss/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/scss/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass version 9.0.0 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:108:19)
    at Object.sassLoader (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:46:20)
ERROR in ./node_modules/@accelerate/prime-ng/resources/themes/gm/theme.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./node_modules/@accelerate/prime-ng/resources/themes/gm/theme.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass version 9.0.0 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:108:19)
    at Object.sassLoader (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:46:20)
ERROR in ./src/app/app.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass version 9.0.0 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:108:19)
    at Object.sassLoader (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:46:20)
ERROR in ./src/app/components/home/home.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass version 9.0.0 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:108:19)
    at Object.sassLoader (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:46:20)
ERROR in ./src/app/components/mast/mast.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass version 9.0.0 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:108:19)
    at Object.sassLoader (C:\Users\Documents\Repositories-GitHub\IDM_157256_device-hierarchy-ui\node_modules\sass-loader\lib\loader.js:46:20)

这是我的package.json

{
  "name": "@accelerate/prime-ng-quick-start",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@accelerate/prime-ng": "0.0.47",
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "^8.2.0",
    "@angular/compiler": "^8.2.0",
    "@angular/core": "^8.2.0",
    "@angular/forms": "^8.2.0",
    "@angular/material": "^8.2.0",
    "@angular/platform-browser": "^8.2.0",
    "@angular/platform-browser-dynamic": "^8.2.0",
    "@angular/router": "^8.2.0",
    "chart.js": "^2.9.3",
    "classlist.js": "^1.1.20150312",
    "css-element-queries": "^1.2.0",
    "font-awesome": "^4.7.0",
    "ng-mocks": "^9.0.0",
    "normalize.css": "^8.0.1",
    "primeflex": "^1.0.0",
    "primeicons": "^2.0.0",
    "primeng": "^8.1.1",
    "quill": "^1.3.7",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.4",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.0",
    "@angular/cli": "~8.2.0",
    "@angular/compiler-cli": "^8.2.0",
    "@angular/language-service": "^8.2.0",
    "@types/jasmine": "^3.3.10",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^11.11.3",
    "codelyzer": "^5.2.2",
    "jasmine": "^3.5.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.1.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "^5.4.2",
    "ts-node": "^8.0.3",
    "tslint": "^5.16.0",
    "typescript": "^3.5.3"
  }
}

我的package.json中没有node-sass或sass。奇怪的是,我的朋友正在使用与我相同的所有版本:节点、cli、环境变量等,他的工作正常,但我看到这些错误,我不明白为什么我会收到此错误。我不想安装任何其他软件包,因为我知道它已经在我朋友的机器上运行了。

javascript node.js angular webpack sass
1个回答
0
投票

如果它对您朋友有用,您可以遵循以下场景之一:

  1. 从你的朋友那里获取
    package-lock.json
    文件并运行
    npm ci
  2. ^
    文件中的所有版本中删除所有
    ~
    (或将其替换为
    package.json
    )并运行
    npm i

一般来说要注意这些:

  1. npm i
    npm ci
    做什么
  2. 从头开始解析软件包版本时
    ^
    ~
    做什么 (
    npm i
    )
© www.soinside.com 2019 - 2024. All rights reserved.