If you have node_modules
folder and package-lock.json
file in your root directory then remove those:
rm -r node_modules
rm package-lock.json
Then run commands:
npm install --save --legacy-peer-deps
npm audit fix --force
Create .env
file in the root directory and paste below code:
SKIP_PREFLIGHT_CHECK=true
Now, start your project:
npm start
我曾多次遇到此问题,最终找到了解决方案:
npm install react-native-paper --legacy-peer-deps
使用 Angular 13 为我安装单词,命令为 npm install --save --legacy-peer-deps。
我刚刚更新了我的Node.js,现在它可以正常工作:
node -v
输出:
V xxxx
并且:
sudo npm install -g n
sudo n stable
我们在 Azure-Pipelines 中使用npm ERR!code ERESOLVE npm
ERR!ERESOLVE 无法解析 npm
ERR! npm
ERR! 在解析时:@angular/material-moment-adapter@12.1.4 npm
ERR!找到:@angular/material@12.0.6 npm
ERR! node_modules/@angular/material npm
ERR! @angular/material@"~12.0.4" 来自根项目
...
npm ci
进行干净的安装。npm install
并推送新的 package-lock.json
。 - task: Npm@1
displayName: npm install
inputs:
command: custom
customCommand: ci
customRegistry: useNpmrc
# ##vso[task.logissue type=error] writes the text to the summary page (error-log).
- bash: echo "##vso[task.logissue type=error] If 'npm install' fails with 'ERESOLVE could not resolve', 'package.json' and 'package-lock.json' (needed for 'npm ci') may be out of sync. Run 'npm install' locally and push the new package-lock.json."
condition: failed() # Only execute on fail
displayName: npm install failed hint
legacy-peer-deps=true
在我们的
.npmrc
文件中覆盖依赖关系。
因此,我认为有时候最好使用legacy-peer-deps来覆盖项目包中不需要的依赖关系。
ERESOLVE 无法解析依赖树。这是在一个使用来自 Azure DevOps 私有 npm 源的一些包的 Angular 13 项目中发生的。
In my library Package.json, update the name to have a scope name @mylib
"name": "@myLib/command-queue",
Build and publish this package to my private feed
In my client app (the one that uses this package), update the .npmrc file to use my private feed for packages in this scope only
@myLib:registry=https://pkgs.dev.azure.com/...
always-auth=true
"@angular/platform-browser-dynamic": "~13.3.0",
"@angular/router": "~13.3.0", <-- this comes from npm
"@myLib/jcg-command-queue": "^2.2.0", <-- This comes from my private feed
我在我的Macbook Pro 2016上执行了这个命令,它对我起作用了。
> npm install --legacy-peer-deps
那么
> npm install
npm i --force
并且
npm i -legacy-peer-deps
npm i --force
命令是与 Node Package Manager (npm) 一起使用的,用于强制安装包。当你运行这个命令时,npm 将安装指定的包,即使它们与你的项目的当前版本不兼容,或者存在与其他依赖项冲突的潜在问题。npm i --legacy-peer-deps
时,npm 将使用旧的、更灵活的算法来解决对等依赖关系,这类似于 npm 版本 4 及更早版本中解决对等依赖关系的方式。这在某些情况下很有帮助,例如包没有更新以声明与 npm 5 引入的更严格的对等依赖关系规则的兼容性。而且,这个问题在你的项目中仍然存在。每当你尝试安装任何其他项目时,你都必须扩展安装选项 --force
或 --legacy-peer-deps
。node_modules
和 package-lock.json
。npm cache clean --force
package.json
中的所有包列在记事本中。package.json
中移除依赖项。npm i package1 package2
这是一个Node.js版本的问题。一些最新版本的Node.js可能会显示类似这样的错误。
我使用 NVM 来管理系统上的 Node.js 版本,并使用 Node.js 12 来解决此错误。
更改版本的命令:
nvm use 12
npm install
,这对我起作用了。 - Huzaifa