npm link报错怎么解决?

λ npm link
npm WARN app@1.0.0 No repository field.

up to date in 0.724s
npm ERR! path C:\Users\Cooper\AppData\Roaming\npm\node_modules\app\app
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\Cooper\AppData\Roaming\npm\node_modules\app\app'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Cooper\AppData\Roaming\npm-cache\_logs\2018-04-06T17_15_16_211Z-debug.log

package.json文件如下:

{
  "name": "app",
  "version": "1.0.0",
  "description": "玩转命令行开发",
  "main": "index.js",
  "bin": {
    "app": "app"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "cooper",
  "license": "ISC",
  "devDependencies": {
    "chalk": "^2.3.2",
    "commander": "^2.15.1",
    "inquirer": "^5.2.0"
  }
}
阅读 14.2k
3 个回答

楼主的实际代码应该是写在了app.js中,把package.json中bin里面的"app": "app"改成"app": "app.js"应该就可以了

"bin": {
    "app": "app"
}

要指定到文件,添加后缀名"app": "app.js"

看看你的package.json文件的内容

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