1. npm reports an error:
Looking at a project today, an error was reported when executing npm install to install dependencies:
84 error code ENOTFOUND 85 error errno ENOTFOUND 86 error network request to https://npm.***.com/@umijs%2fpreset-react failed, reason: getaddrinfo ENOTFOUND npm.***.com npm.***.com:443 87 error network This is a problem related to network connectivity. 87 error network In most cases you are behind a proxy or have bad network settings. 87 error network 87 error network If you are behind a proxy, please make sure that the 87 error network 'proxy' config is set properly. See: 'npm help config'
ENOTFOUND npm ERR! network request to https://npm.zhonganonline.com/@umijs%2fpreset-react failed
It means that the registration address of this mirror cannot be found.
Why is there such a situation? Aren’t all npm installation mirror addresses downloaded from npm? So look at the project structure and found the .npmrc file
2. The role of the .npmrc file
There may be a .npmrc file in the root directory of some projects. When you click to open it, there is only one sentence: registry= http://registry.npm.xxxx.com
Is the npm warehouse mirror address
In npm i, if there is this file in the project root directory, node_modules will be automatically installed from this mirror address, and there is no need to manually set the mirror address.
So the problem is that there is a problem with the mirror address in the .npmrc file, just delete this file.
3. npm configuration and .npmrc file
(1) npm cli provides the npm config command for npm related configuration, through npm config ls -l you can view all the configurations of npm, including the default configuration.
(2) npm config set to modify the configuration items, after using the command configuration, all the comments in the configuration file will be deleted
(3) Some common configurations:
proxy, https-proxy: Specify npm to use a proxy
registry specifies the source of the npm download and installation package. Default: https://registry.npmjs.org/
npm config set prefix $dir
Read More:
- NPM Install Error: npm ERR! ERESOLVE unable to resolve dependency tree
- [Solved] Executing npm install error: npm ERR! code EINTEGRITY
- Vue Error: command failed: npm install –loglevel error –registry=https://registry.npm.taobao.org
- npm install npm ERR code ERESOLVE [How to Solve]
- Vue-element-admin Use npm install Error: npm ERR! Error while executing:
- NPM install error: Cannot find module ‘D:\zip\node_modules\npm\bin\npm-cli.js‘
- Vue Package Error: npm ERR! missing script: build
- Cli Write Error: This is related to npm not being able to find a file. [Solved]
- NPM install -g create-react-app [How to Solve]
- How to Solve NPM update check failed Error
- [Solved] NPM Install Error: EPERM: operation not permitted, mkdir xxx
- NPM run dev Error Module build failed: Error: Cannot find module ‘node-sass’
- [Solved] This usually happens because your environment has changed since running `npm install`
- [Solved] Mac Notebook M1 Chip Install Hashlips library npm error
- Cocos creator custom engine NPM Error [How to Fix]
- [Solved] NPM Error: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed
- Commit failed – exit code 1 received, with output: ‘>running pre-commit hook: npm run precommit (Fixed)
- [Solved] NPM Error: gyp: No Xcode or CLT version detected!
- [Solved] cnpm: Cannot load the file C:\Users\Raytine\AppData\Roaming\npm\cnpm.ps1 because running scripts is prohibited on this system
- Jenkins uses NPM to build Vue error, and the manual build is normal