针对pnpm运行的代码,但是npm install不能运行报错的解决方案

报错信息

npm install
npm WARN deprecated [email protected]: 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

[email protected] preinstall

Need to install the following packages:
[email protected]
Ok to proceed? (y) y
╔═════════════════════════════════════════════════════════════╗
║ ║
║ Use “pnpm install” for installation in this project. ║
║ ║
║ If you don’t have pnpm, install it via “npm i -g pnpm”. ║
║ For more details, go to https://pnpm.js.org/ ║
║ ║
╚═════════════════════════════════════════════════════════════╝
npm ERR! code 1
npm ERR! path E:\mess\pure-admin-thin
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npx only-allow pnpm

npm ERR! A complete log of this run can be found in: E:\node\node_cache_logs\2023-09-11T08_05_37_392Z-debug-0.log

added 1 package in 2s

问题背景

因为我从github上拉代码 (pure admin)的时候,运行的时候报错,因为我使用的是npm install
实际上你使用pnpm install能使用的话就没问题
不能的话看下面的解决方法

解决

在使用npm install的时候,报错信息上面说了如果没有pnpm就使用npm i -g pnpm
结果还是差一个包
再引入npm install vue-demi
然后用npm run serve(可能不是serve看项目配置)

解决成功

补充

如果提示node版本问题可能是node版本太低了,需要进行升级

补充2

我之后又遇到了sass的问题,解决办法是删掉modules里面的sass包然后重新npm i -g pnpm,和npm install vue-demi然后就好了

你可能感兴趣的:(npm,前端,node.js)