npm install安装包后,运行npm start提示的版本冲突

mac2024-04-08  44

真烦npm install的前端,运行一个同事的项目要么装得超级超级慢,要么装了以后说引用包有冲突,npm intall成功后,npm start却跑不起来。

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.   2. Delete node_modules in your project folder.   3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.   4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.      This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if E:\nodejs\lerna\packages\pgis-app\node_modules\webpack is outside your project directory.      For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls webpack in your project folder.      This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway.

根据提示rm package-lock.json + rm node_modules + rm yarn.lock + npm install后还是不行,前四步无效后,继续看后三步,主要解决方式其实在最后一步:

先 npm ls webpack 查看冲突的包版本

然后npm install webpack@4.28.3 把冲突包安装

npm start总算是能正常运行了,真心浪费时间……

 

最新回复(0)