来自github的npm包,缺少文件

时间:2016-04-06 20:03:22

标签: javascript github npm npm-install

我正在尝试从我的项目中引用logary-js

我有这个packages.json文件:

...
"dependencies": {
  "logary": "logary/logary-js#master",
  ...
}
...

但是,当尝试下拉包时,它会因此错误而失败:

✗ npm install

> logary@1.0.0 preinstall /Users/h/dev/proj/node_modules/.staging/logary-6603d70a
> npm run build


> logary@1.0.0 build /Users/h/dev/proj/node_modules/.staging/logary-6603d70a
> NODE_ENV=production webpack --progress --color --display-error-details --display-reasons --optimize-minimize

webpack 1.12.14
Usage: https://webpack.github.io/docs/cli.html

Options:
  --help, -h, -?
  --config
  --context
  --entry
  --module-bind
  --module-bind-post
  --module-bind-pre
  --output-path
  --output-file
  --output-chunk-file
  --output-named-chunk-file
  --output-source-map-file
  --output-public-path
  --output-jsonp-function
  --output-pathinfo
  --output-library
  --output-library-target
  --records-input-path
  --records-output-path
  --records-path
  --define
  --target
  --cache                                                                                           [default: true]
  --watch, -w
  --watch which closes when stdin ends
  --watch-aggregate-timeout
  --watch-poll
  --hot
  --debug
  --devtool
  --progress
  --resolve-alias
  --resolve-loader-alias
  --optimize-max-chunks
  --optimize-min-chunk-size
  --optimize-minimize
  --optimize-occurence-order
  --optimize-dedupe
  --prefetch
  --provide
  --labeled-modules
  --plugin
  --bail
  --profile
  -d                                    shortcut for --debug --devtool sourcemap --output-pathinfo
  -p                                    shortcut for --optimize-minimize
  --json, -j
  --colors, -c
  --sort-modules-by
  --sort-chunks-by
  --sort-assets-by
  --hide-modules
  --display-exclude
  --display-modules
  --display-chunks
  --display-error-details
  --display-origins
  --display-cached
  --display-cached-assets
  --display-reasons, --verbose, -v

Output filename not configured.

npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/h/.nvm/versions/node/v5.6.0/bin/node" "/Users/h/.nvm/versions/node/v5.6.0/bin/npm" "run" "build"
npm ERR! node v5.6.0
npm ERR! npm  v3.6.0
npm ERR! code ELIFECYCLE
npm ERR! logary@1.0.0 build: `NODE_ENV=production webpack --progress --color --display-error-details --display-reasons --optimize-minimize`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the logary@1.0.0 build script 'NODE_ENV=production webpack --progress --color --display-error-details --display-reasons --optimize-minimize'.

如果目录中没有webpack.config.js文件,则会出现错误。这让我相信npm只会删除一些文件。 npm-debug.log说:

89 verbose tar unpack /Users/h/.npm/logary/1.0.0/package.tgz
90 verbose tar unpacking to /Users/h/dev/proj/node_modules/.staging/logary-6603d70a
91 silly gentlyRm /Users/h/dev/proj/node_modules/.staging/logary-6603d70a is being purged
92 verbose gentlyRm don't care about contents; nuking /Users/h/dev/proj/node_modules/.staging/logary
-6603d70a
93 silly gunzTarPerm modes [ '770', '660' ]
94 silly gunzTarPerm extractEntry package.json
95 silly gunzTarPerm extractEntry README.md
96 silly gunzTarPerm extractEntry LICENSE
97 silly gentlyRm /Users/h/dev/proj/node_modules/.staging/logary-6603d70a/node_modules is being purg
ed
98 verbose gentlyRm don't care about contents; nuking /Users/h/dev/proj/node_modules/.staging/logary
-6603d70a/node_modules
99 silly doParallel preinstall 1
100 silly preinstall logary@1.0.0 /Users/h/dev/proj/node_modules/.staging/logary-6603d70a
101 info lifecycle logary@1.0.0~preinstall: logary@1.0.0

此外,在这个示例https://github.com/logary/logary-js/tree/master/examples/webpack中,它引用了逻辑,虽然通过文件系统而不是github。

所以问题就变成了;我如何从github引用logary?或者我应该在package.json文件中更改哪些内容才能使其正常工作?

1 个答案:

答案 0 :(得分:0)

您可以使用语法npm install --save https://github.com/{USER}/{REPO}/tarball/{BRANCH}从GitHub安装Node包。您也可以查看此answer,它有很好的提示。