我正在尝试用npm安装 github项目的一个fork(在master而不是任何特定的提交,因为我想针对它开发): % npm install parkan/graffiti-mongoose@risingstack/graffiti-mongoose@2.0.0 node_modules/@risingstack/graffiti-mong
% npm install parkan/graffiti-mongoose @risingstack/graffiti-mongoose@2.0.0 node_modules/@risingstack/graffiti-mongoose
这看起来像查找父回购并在我的gh上安装版本的master版本,到目前为止一切顺利.请注意,该软件包使用scoped package name semantics,我认为这是问题的一部分.
% npm list |grep mongoose ├── @risingstack/graffiti-mongoose@2.0.0 (git://github.com/parkan/graffiti-mongoose.git#01a8480fa7d787a4d74bf3bcb257d01b4d73129a) % ls node_modules/@risingstack/graffiti-mongoose CHANGELOG.md LICENSE fixture CONTRIBUTING.md README.md package.json
但是,我无法以任何明显的方式导入节点或要求它:
> require('graffiti-mongoose'); Error: Cannot find module 'graffiti-mongoose' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at repl:3:1 at Object.exports.runInThisContext (vm.js:54:17) at _eval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:86:26) at REPLServer.replEval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:169:14) at bound (domain.js:250:14) at REPLServer.runBound [as eval] (domain.js:263:12) > require('@risingstack/graffiti-mongoose'); Error: Cannot find module '@risingstack/graffiti-mongoose' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at repl:3:1 at Object.exports.runInThisContext (vm.js:54:17) at _eval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:86:26) at REPLServer.replEval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:169:14) at bound (domain.js:250:14) at REPLServer.runBound [as eval] (domain.js:263:12) > require('risingstack/graffiti-mongoose'); Error: Cannot find module 'risingstack/graffiti-mongoose' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at repl:3:1 at Object.exports.runInThisContext (vm.js:54:17) at _eval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:86:26) at REPLServer.replEval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:169:14) at bound (domain.js:250:14) at REPLServer.runBound [as eval] (domain.js:263:12)
我如何需要一个像这样的子目录中的包?
这似乎是npm中的一个错误.检出repo并从本地文件系统安装工作正常.提交的问题:https://github.com/npm/npm/issues/9798
编辑:这似乎是在未检入工件且必须在模块可用之前运行预发布脚本的情况下从github安装的限制,请参阅https://github.com/npm/npm/issues/3055