问题:
在一个项目里安装webpack的时候出现如下报错信息。
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "webpack" under a package
npm ERR! also called "webpack". Did you name your project the same
npm ERR! as the dependency you're installing?
解决:
出现上述错误,说明你执行命令的目录里有一个package.json
文件,并且该文件里的name
字段就叫webpack。
只需换个名字就好了。
总结:
npm install xxxx 命令会将安装包的名字及版本保存在package.json文件中
package.json文件中的name字段的值,不能与所要安装的依赖包名字相同。
package.json
:https://classic.yarnpkg.com/zh-Hans/docs/package-json/