本地包npm错误

时间:2015-10-12 21:01:14

标签: node.js path npm dependencies

我将这个依赖项添加到我的package.json:

"user": "file:./server/models/user"

在我的用户文件中,我有module.exports = function() {...}

npm ERR! addLocal Could not install /home/WebstormProjects/project/server/models/user
npm ERR! Linux 3.19.0-30-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! path /home/WebstormProjects/project/server/models/user
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/home/WebstormProjects/project/server/models/user'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/WebstormProjects/project/npm-debug.log

我的确遵循了文档:https://docs.npmjs.com/files/package.json#local-paths

1 个答案:

答案 0 :(得分:0)

错误消息不是很有用,但必须是(强调我的):

  

包含的本地目录的路径

https://docs.npmjs.com/files/package.json#local-paths

您似乎将其指向文件。你可能需要这样的东西:

"user": "file:./server/models"

套餐还需要package.json,因此在这种情况下您需要server/models/package.json