Every front-end engineer must rely on Node and NPM to develop Vue and React. However, the installation environment is always the most problematic step, which is often a headache for many entry-level front-end engineers. Next, I will share with you my personal node experience and bug attribution and how to solve the summary.
Start from the mirror source of Node, download node default source is foreign, in China may be relatively, there may be a connection or installation speed is slow, we can choose the domestic Taobao mirror.
NPM config get registry # view the current source of NPM NPM config set registry https://registry.npm.taobao.org # modified sourceCopy the code
Node Version Download
The specified version can be downloaded from the official website nodejs.org/en/download… , relative to small white first download is relatively easy to use
For different project engineers need different versions of node can also download the use of NVM management node, I test or very good, choose the version, it is recommended not to use too new or too old, stable version of the best to use, of course, except big cow use.
NPM install Installation error summary
- Environment variables To set whether the path is correctly configured
2. Check whether the NPM installation path is correctly configured in. NPMRC
3. NPM install roughly error point. After modifying these environment variables, the most important thing is to update the cache, restart the computer, and kill the process. Usually your project will work.
NPM cache clean --force # Delete cacheCopy the code
NPM install error package-lock.json
Bug origin
Example: If you pull back the vue project from git and the local configuration is correct, an installation error occurs.
Json file, such as “Roadhog “: “^2.6.0-beta.4”. The latest version of 2.x.x will be installed during installation. Because the module was updated during this period, the two versions of install are different, so the project reported an error.
Solution: There are many ways to solve this problem. The simplest way is to delete package-lock.json and install NPM again.
One hundred programs ape one hundred solutions, welcome every big guy who reads this blog comments!