npm install报错

运行npm install之后:报错如下

PS D:\item\jjjshop-java\jjj_shop_single_admin> npm install 
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the 
compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated flatten@1.0.2: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.3: this library is no longer supported
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated acorn-dynamic-import@2.0.2: This is probably built in to whatever tool you're using. If you still need it... idk 
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated html-webpack-plugin@2.30.1: out of support
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated extract-text-webpack-plugin@3.0.2: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.3.3: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated source-map-resolve@0.5.2: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API 
surface has changed to use Promises in 1.x.)
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm WARN deprecated bfj-node4@5.3.1: Switch to the `bfj` package for fixes and new features!
npm WARN deprecated axios@0.19.0: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm WARN deprecated buffer@4.9.1: This version of 'buffer' is out-of-date. You must update to v4.9.2 or newer
npm WARN deprecated svgo@0.7.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated svgo@1.3.0: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated core-js@2.6.10: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: D:\IT_Instrument\nodejs\node.exe D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\node-gyp\bin\node-gyp.js 
rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'D:\\IT_Instrument\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\item\\jjjshop-java\\jjj_shop_single_admin\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.14.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python". checking python launcher
npm ERR! gyp verb could not find "python". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "D:\\IT_Instrument\\nodejs\\node.exe" "D:\\item\\jjjshop-java\\jjj_shop_single_admin\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\23698\AppData\Local\npm-cache\_logs\2023-05-09T09_38_34_852Z-debug-0.log

这是因为node-sass和sass-loadr与node版本不适配导致的

解决:

1.执行命令:卸载 node-sass

npm uninstall node-sass

出现如下效果就是成功:

PS D:\item\jjjshop-java\jjj_shop_single_admin> npm uninstall node-sass
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the 
compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated acorn-dynamic-import@2.0.2: This is probably built in to whatever tool you're using. If you still need it... idk
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated html-webpack-plugin@2.30.1: out of support
npm WARN deprecated extract-text-webpack-plugin@3.0.2: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
s, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm WARN deprecated bfj-node4@5.3.1: Switch to the `bfj` package for fixes and new features!
npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm WARN deprecated svgo@0.7.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issuesfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

added 1342 packages in 17s

也可以用node-sass -v来测试:如下就是卸载完成

PS D:\item\jjjshop-java\jjj_shop_single_admin> node-sass -v
node-sass : 无法将“node-sass”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然   
后再试一次。
所在位置 行:1 字符: 1
+ node-sass -v
    + CategoryInfo          : ObjectNotFound: (node-sass:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

2.安装与本机node版本相对应的node-sass版本 

我的版本号:

 与之对应的node-sass版本号:网址:

node-sass - npm

 所以我要装6.0+ 执行命令:

npm install node-sass@6.0.1

显示完成:

PS D:\item\jjjshop-java\jjj_shop_single_admin> npm install node-sass@6.0.1
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

在运行npm run dev  会出现下面错误:这是因为sass-loader版本不适

PS D:\item\jjjshop-java\jjj_shop_single_admin> npm run dev

> jjj_shop_web@1.0.0 dev
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

(node:7708) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
 14% building modules 40/105 modules 65 active ...ava\jjj_shop_single_admin\src\App.vue{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
 94% asset optimization

 ERROR  Failed to compile with 4 errors                                                                                      17:45:17

 error  in ./src/App.vue

Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:165:13)
    at Object.loader (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:79:18)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-7ba5bd90","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/sass-resources-loader/lib/loader.js?{"resources":"D://item//jjjshop-java//jjj_shop_single_admin//src//styles//index.scss"}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-512 13:3-17:5 14:22-520
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js

 error  in ./src/views/Login.vue

Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:165:13)
    at Object.loader (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:79:18)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-26084dc2","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/sass-resources-loader/lib/loader.js?{"resources":"D://item//jjjshop-java//jjj_shop_single_admin//src//styles//index.scss"}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/views/Login.vue 4:14-528 13:3-17:5 14:22-536
 @ ./src/views/Login.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js

 error  in ./src/views/home/Home.vue

Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:165:13)
    at Object.loader (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:79:18)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-3dd2e005","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/sass-resources-loader/lib/loader.js?{"resources":"D://item//jjjshop-java//jjj_shop_single_admin//src//styles//index.scss"}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/views/home/Home.vue 4:14-543 13:3-17:5 14:22-551
 @ ./src/views/home/Home.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js

 error  in ./src/views/layout/Head.vue

Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
    at getRenderFuncFromSassImpl (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:165:13)
    at Object.loader (D:\item\jjjshop-java\jjj_shop_single_admin\node_modules\sass-loader\dist\index.js:79:18)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":todules/sass-resources-loader/lib/loader.js?{"resources":"D://item//jjjshop-java//jjj_shop_single_admin//src//styles//index.scss"}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/views/layout/Head.vue 4:14-543 13:3-17:5 14:22-551
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/views/layout/RightContent.vue 
 @ ./src/views/layout/RightContent.vue
 @ ./src/views/layout/Main.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js

3.先卸载 sass-loader 执行下面命令

npm uninstall sass-loader

4.执行命令:

npm i sass-loader@4.0.0 --save-dev

5.执行命令 :

npm run dev

完成 如下:

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值