Solutions to errors such as "Cannot read properties of null (reading 'pickAlgorithm')" when npm install compiles

1. Problem background:

    Like 'vue-cli-service' is not an internal or external command, nor a runnable program or batch file, Error loading vue.config.js: ERROR Error: Cannot find module './vue.config_undefined', etc. For errors reported during npm install compilation, we can use the following three methods:

2. Solution:

1. Clear the cache npm cache clear --force and then reinstall the dependency npm install

2. (1) Deleted node models, re-npm install download

 (2) Or directly download CNPM (Taobao Mirror) to install CNPM installation method

 npm install -g cnpm -registry=https://registry.npm.taobao.org

 Check whether cnpm is installed successfully cnpm -v

Note: It is not recommended to use mirror cnpm, because although it is fast, there may be loss or other errors.

3. Reinstall node to solve 

The above three methods are suitable for most situations and can be solved. If none of the above can be solved, in addition to the above three more classic solutions, there is another method, which is suitable for node version problems. The possible version of node originally used by the project is lower, and our node version is higher, so an error will be reported.

However, when we just upgraded node and updated node from the original low version to a high version, the problem was not completely solved . At this time, it is normal to recompile and compile, but there are remaining problems, that is, recompile after node_modules is deleted The above error will appear. The reason may be that the node_modules compiled by our low-version node has not been deleted. The things compiled by the low-version node that the project has been reading make us think that the newly installed high-version node is successful.

Solution, find package-lock.jsonthe file. Keep the red circled content in the picture, delete all the rest, and then npm installrecompile, package-lock.json will generate a new file. Finally compiled successfully. be resolved.

 The package-lock.json generated by node13 may have undergone major changes in structure from the package-lock.json of node16. So we use the package-lock.json generated by node13 to let node16 parse it, it must not be parsed. We deleted all the content, and node16 generated a new content for us. In theory, it will not affect our project, because the versions of the various packages we use are defined in package.json, and the version dependencies in the generated package-lock.json are also generated with reference to package.json, and Does not affect the use of the overall framework.

Guess you like

Origin blog.csdn.net/coinisi_li/article/details/127965050