文章标题

来源:互联网 发布:森汉机器人编程软件 编辑:程序博客网 时间:2024/06/12 21:50

webpack 使用出现的问题

照着教程写的代码,发现在项目根目录运行 webpack 却出现了问题

throw err; Error: Cannot find module ‘webpack/lib/node/NodeTemplatePlugin’

查了资料找到原因是全局安装了webpack
解决方法是在本项目安装 npm install webpack

于是就兴高采烈地照着干,结果

D:\nodejs\webpack>npm install webpack
npm ERR! Windows_NT 6.1.7601
npm ERR! argv D:\nodejs\node.exe”D:\nodejs\node_modules\npm\bin\npm-cl
i.js” “install” “webpack”
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
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! D:\nodejs\webpack\npm-debug.log

这就奇怪了,为什么?
又得继续百度,

赶紧将package.json中的name字段清空。

完了继续在根目录执行 webpack ,结果OK了。

原创粉丝点击