我正在为NodeJS开发两个模块,一个模块名为aligator,第二个模块名为aligator-methods。第二个取决于第一个去工作。我正在同时开发这两个模块,我想要全局链接aligator,这样我就可以像在npm注册中心那样使用它,并且我只是在全球安装它。要做到这一点,NPM文档说,我需要使用npm link,但它不起作用。
模块package.json文件aligator
{
"name": "aligator",
"version": "0.0.1",
"description": "",
"main": "index.js",
"private": true,
"directories": {
"doc": "docs",
"example": "examples",
"test": "spec"
},
"scripts": {
"test": "gulp jasmine"
},
"license": "MIT",
"devDependencies": {
"gulp": "^3.6.2",
"gulp-jasmine": "^0.2.0",
"gulp-jshint": "^1.6.1",
"gulp-rename": "^1.2.0",
"jasmine-node": "^1.14.3"
},
"dependencies": {
"bluebird": "^1.2.4",
"lodash": "^2.4.1",
"mathjs": "^0.22.0"
}
}模块package.json文件aligator-methods
{
"name": "aligator-methods",
"version": "0.0.1",
"description": "",
"main": "index.js",
"private": true,
"directories": {
"doc": "docs",
"example": "examples",
"test": "jasmine"
},
"scripts": {
"test": "gulp jasmine"
},
"author": "",
"license": "MIT",
"devDependencies": {
"gulp": "^3.6.2",
"gulp-jasmine": "^0.2.0",
"gulp-jshint": "^1.6.1",
"gulp-rename": "^1.2.0",
"jasmine-node": "^1.14.3"
},
"dependencies": {
"lodash": "^2.4.1",
"mathjs": "^0.22.0",
"aligator": "^0.0.1"
}
}首先,我在全球范围内链接了该模块:
$ cd ~/aligator
$ npm link
/usr/local/lib/node_modules/aligator -> /Users/roc/aligator如果我没有弄错的话,我已经为我的模块aligator创建了一个全局引用,现在我可以在计算机中的任何地方使用这个模块。
然后我转到另一个模块,试图安装这个依赖项,但是它给了我这个输出:
$ cd ~/aligator-methods
$ npm install
npm ERR! 404 404 Not Found: aligator
npm ERR! 404
npm ERR! 404 'aligator' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 It was specified as a dependency of 'aligator-methods'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Darwin 13.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/roc/aligator-methods
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.16
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/roc/aligator-methods/npm-debug.log
npm ERR! not ok code 0我甚至试图把它直接连接到:
$ cd ~/aligator-methods
$ npm link aligator
/Users/roc/aligator-methods/node_modules/aligator -> /usr/local/lib/node_modules/aligator -> /Users/roc/aligator但也没用。
对可能发生的事情有什么想法吗?,我在某个地方读到,这可能与我安装node和npm有关,因为它是由自制的,所以有时我需要使用sudo,这似乎不太可能,但我尝试了他们的提议,但也没有奏效。
发布于 2020-01-29 09:54:13
问题在于package.json的package.json属性指向一个不存在的文件。似乎这个问题可能会因为多种原因而发生,所以一定要看看其他的答案。
发布于 2016-12-06 16:56:27
由于NVM,我遇到了这个问题,我运行一个版本的节点作为依赖项,另一个版本用于依赖者。
发布于 2018-11-14 11:39:39
删除package-lock.json,然后再次运行npm install,为我解决了这个问题。
https://stackoverflow.com/questions/24550515
复制相似问题