Node.js resolves name conflict errors during installation
The installation of the package cannot be completed in node.js, and an error is reported: npm ERR! code ENOSELF npm ERR! Refusing to install package with name “moment” under a package npm ERR! also called “moment”.
The steps I started with:
-
Created a folder called "moment"
-
Open the terminal in the "moment" folder of the directory where the command is executed, and enter the npm init -y command in the terminal to quickly create the package.json package management configuration file
-
I want to download and install a moment package, which will be used to complete subsequent formatting time operations in the future
*存在 **npm ERR! Refusing to install package with name “moment” under a package also called “moment”. *报错 ;
Reasons for download failure:
During initialization, the project name "moment" (that is, the folder name) created by default is the same as the package name "moment" I want to install, and there is a conflict, resulting in the failure to complete the normal installation
The value of the name field in package.json conflicts with the name of the package to be installed
Solution
- _Modify the value of the name field in package.json_The
specific modification method is as follows: inputnpm initcommand to modify the corresponding field value