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

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

Refusing to install webpack as a dependency of itself

 1 npm ERR! Windows_NT 10.0.14393
 2 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "webpack" "--save-dev"
 3 npm ERR! node v7.1.0
 4 npm ERR! npm v3.10.9
 5 npm ERR! code ENOSELF
 6 
 7 npm ERR! Refusing to install webpack as a dependency of itself
 8 npm ERR!
 9 npm ERR! If you need help, you may report this error at:
10 npm ERR! <https://github.com/npm/npm/issues>
11 
12 npm ERR! Please include the following file with any support request:
13 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"。