webpack笔记_(2)_Refusing to install webpack as a dependency of itself

时间:2024-09-01 20:04:50

安装webpack时,出现以下问题:

Refusing to install webpack as a dependency of itself

 npm ERR! Windows_NT 10.0.
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "webpack" "--save-dev"
npm ERR! node v7.1.0
npm ERR! npm v3.10.9
npm ERR! code ENOSELF npm ERR! Refusing to install webpack as a dependency of itself
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues> npm ERR! Please include the following file with any support request:
npm ERR! F:\ProgramWork\React\React_Note\WebReact\webpack_react\npm-debug.log

原因是:不能安装webpack到自身目录。

解决方案:

1.如果本次安装的目录下没有 package.json 文件。

直接修改本次安装的目录。确保目录中没有同名的“webpack”文件路径。

2.如果目录中包含 package.json

修改1中的内容外。需要修改package.json中的 “name”字段的值:

如 "name": "webpackProject",不能设定为: "name": "webpack"。