6 个回答

我装webpack的时候也出现了这个问题

Refusing to install webpack as a dependency of itself

当时我的package.json是这个样子的

{
  "name": "webpack",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {

  }
}

然后我把name字段改成webpacktest就好了,没错!就好了,太神奇了

{
  "name": "webpacktest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "gulp": "^3.9.1",
    "webpack": "^1.13.0"
  }
}

没错,package.json文件的name名字不能跟npm模块相同。

打开 package.json 删除 里面 关于 grunt的信息

新手上路,请多包涵

网络不好网络不好网络不好

楼上是对的 name不能和devDependencies里的模块名相同图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题