尝试从GitHub安装模块会导致以下错误:

package.json上的ENOENT错误。

容易复制使用express:

NPM安装https://github.com/visionmedia/express抛出错误。

NPM安装快速工程。

为什么我不能从GitHub安装?

下面是控制台输出:

npm http GET https://github.com/visionmedia/express.git
npm http 200 https://github.com/visionmedia/express.git
npm ERR! not a package /home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/tmp.tgz
npm ERR! Error: ENOENT, open '/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.8.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "https://github.com/visionmedia/express.git"
npm ERR! cwd /home/guym/dev_env/projects_GIT/proj/somename
npm ERR! node -v v0.10.10
npm ERR! npm -v 1.2.25
npm ERR! path /home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/guym/dev_env/projects_GIT/proj/somename/npm-debug.log
npm ERR! not ok code 0

当前回答

直接安装:

npm install visionmedia/express

或者,你可以在package的“dependencies”部分添加“express”:“github:visionmedia/express”。,然后运行:

npm install

其他回答

你可以通过npm install命令直接安装一个GitHub存储库,就像这样:

npm install https://github.com/futurechallenger/npm_git_install.git --save

注意:在npm命令将要安装的存储库中:

根据Dan Dascalescu的评论,也许你必须在你的存储库中有一个dist文件夹。 你一定要打包。Json在你的存储库!我忘记加了。

不需要做太多;这帮助了我:

Yarn add <git_name>:<github_name>/<Repository_name>.git

例子:

yarn add git@github.com:myGitHub/dynamic-checkbox-input.git

如果你想添加一些特定的提交或分支名称,那么添加#。

例子:

yarn add git@github.com:myGitHub/dynamic-checkbox-input.git#master

例子:

yarn add git@github.com:myGitHub/dynamic-checkbox-input.git#c978U57

你也可以

npm i alex-cory/fasthacks

or

npm i github:alex-cory/fasthacks

基本上:

npm i user_or_org/repo_name

从GitHub安装,你也可以这样做

npm install visionmedia/express

Or

npm install visionmedia/express#branch

也支持直接从Gist, Bitbucket, GitLab和其他一些专门的格式安装。看看npm的安装文档。

如果Git没有安装,我们可以尝试:

npm install --save https://github.com/Amitesh/gulp-rev-all/tarball/master