【问题标题】:npm install github repo strips src foldernpm install github repo 删除 src 文件夹
【发布时间】:2018-02-17 16:26:24
【问题描述】:

我做了以下事情:

npm install TuningGuide/react-sortable-hoc --save
npm info it worked if it ends with ok
npm info using npm@3.10.5
npm info using node@v6.2.2
npm info git [ 'clone',
npm info git   '--template=/Users/velten/.npm/_git-remotes/_templates',
npm info git   '--mirror',
npm info git   'git://github.com/tuningguide/react-sortable-hoc.git',
npm info git   '/Users/velten/.npm/_git-remotes/git-github-com-tuningguide-react-sortable-hoc-git-78a804e9' ]
npm info git [ 'rev-list', '-n1', 'master' ]
npm info git [ 'clone',
npm info git   '/Users/velten/.npm/_git-remotes/git-github-com-tuningguide-react-sortable-hoc-git-78a804e9',
npm info git   '/var/folders/95/ylk5ht9s24n6xk4rcr6sch4r0000gn/T/npm-22395-24e6f9cc/git-cache-220f34bb/09fb1e0c7d657657b9aa091c018b45aee0ed0662' ]
npm info git [ 'checkout', '09fb1e0c7d657657b9aa091c018b45aee0ed0662' ]
npm info git [ 'submodule', '-q', 'update', '--init', '--recursive' ]
npm info attempt registry request try #1 at 14:18:51
npm http request GET https://registry.npmjs.org/invariant
npm http 304 https://registry.npmjs.org/invariant
npm info lifecycle invariant@2.2.1~preinstall: invariant@2.2.1
npm info lifecycle react-sortable-hoc@0.0.7~preinstall: react-sortable-hoc@0.0.7
npm info linkStuff invariant@2.2.1
npm info linkStuff react-sortable-hoc@0.0.7
npm info lifecycle invariant@2.2.1~install: invariant@2.2.1
npm info lifecycle react-sortable-hoc@0.0.7~install: react-sortable-hoc@0.0.7
npm info lifecycle invariant@2.2.1~postinstall: invariant@2.2.1
npm info lifecycle react-sortable-hoc@0.0.7~postinstall: react-sortable-hoc@0.0.7
typescript-react-mobx-boilerplate@1.0.0 /Users/velten/Websites/typescript-react-mobx-boilerplate
└─┬ react-sortable-hoc@0.0.7  (git://github.com/tuningguide/react-sortable-hoc.git#09fb1e0c7d657657b9aa091c018b45aee0ed0662)
  └── invariant@2.2.1 

npm info ok 

但该文件夹不包含源代码或构建。为什么?

【问题讨论】:

  • 您是否尝试重新安装它?结果一样吗?
  • npm cache clean 并重新安装。
  • @WilfredHughes 您引用的问题不相关。 npm 不下载 src 子目录。如您所见,package.json 位于根目录中。
  • 找到相关问题:github.com/npm/npm/issues/3055

标签: node.js github npm


【解决方案1】:

src/ 在.npmignore 文件夹中被禁止(如果我们谈论this repo

https://github.com/clauderic/react-sortable-hoc/blob/master/.npmignore

...而隐含的prepublish 仅在常规“已发布安装”时触发build,如果您直接从 github 安装,不会...(也学到了艰难的方法) .

尝试使用任何知名软件包,不要以标准方式安装,而是直接从 github 安装,以进行验证。

确实很痛苦。在他自己的存储库上可以做的最好的事情是使用“预安装”钩子。 (并且不禁止 src/-Folder 为它工作)。

您可以克隆 repo,允许 src/ 文件夹(从 .npmignore 中删除),并将构建过程移动到“预安装”挂钩...

【讨论】:

  • 关于如何“将构建过程移动到“预安装”挂钩...”的任何建议?
  • 是的,很高兴听到有关此的消息。
【解决方案2】:

您可能需要在 package.json 中为您的 repo 设置 files

【讨论】:

  • 感谢分享!
【解决方案3】:

例如,获取整个 repo 内容的一种解决方法是从存档安装(看起来 repo 已重命名为 clauderic/react-sortable-hoc,因为提出了问题)

$ npm install https://github.com/clauderic/react-sortable-hoc/archive/v0.6.7.tar.gz

这会下载src/,但不会下载build/,它不会在 git 中跟踪。

【讨论】:

    猜你喜欢
    • 2014-01-31
    • 2017-03-24
    • 2017-01-04
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2011-03-21
    • 1970-01-01
    相关资源
    最近更新 更多