Skip to content
This repository has been archived by the owner. It is now read-only.

run `prepublish` for git url packages #3055

isaacs opened this issue Jan 14, 2013 · 81 comments

run `prepublish` for git url packages #3055

isaacs opened this issue Jan 14, 2013 · 81 comments


Copy link

@isaacs isaacs commented Jan 14, 2013

After installing a git url package, perhaps the prepublish script should be run, since git repos will typically not keep around any built artifacts that the prepublish script generates.

However, prepublish scripts also typically require the use of devDependencies packages, so it might not be possible to do this in a good way. (In which case, it'll just be on the users of git url packages to run whatever scripts are necessary to make them ready to use.)

Copy link

@dfellis dfellis commented Jan 15, 2013

I don't believe it's necessary. If the user has forked a project and is installing via a raw git repo, they could add a commit to cause preinstall to run the prepublish script if needed, and leave it alone if they don't.

Copy link

@guybrush guybrush commented Jan 17, 2013

I am with @dfellis after thinking 2 days about this and I am still not sure haha.

My thoughts are:

  • if a package is promoted to be installed via git, this would be unnecessary anyway. the developer will make sure it works.
  • if a package is actually in the registry but installed via git, the user knows what he is doing and will do as @dfellis mentioned (or any other solution)
  • the devDependencies-problem sucks, prepublish is meant to be run on the developer-side

But I think it should be mentioned in the docs maybe?

Copy link

@iki iki commented Apr 29, 2013

use case:

  • condition: package needs to be compiled before installation, e.g. from coffeescript to javascript
  • condition: compiled files are not welcome in the repository
  • goal: allow developer to publish package in registry in a compiled state, so common users do not need any pre/postinstall
  • goal: allow users to install a different versions or forks of the package from git repos without having to do anything special (e.g. as a project dependencies)

sample current solution by @paulmillr at

  • on prepublish compile all and manually turn off postinstall in package,json
  • on postpublish reenable postinstall
  • on postinstall (which runs only when installed via git, as it is disabled in packages in registry): compile all


  • clearly devDependencies will need to be installed for packages with prepublish installed via git repo ... this is ok as long as users did really need to run preinstall, in this case it is the right thing to do
  • complex prepublish scripts may depend on other development tools, that may not be available on user machines


  1. don't do anything, let developers solve that like in ... imho awkward
  2. run prepublish on git install ... will fail packages with complex prepublish scripts installed via git repo (but currently they were just installed unbuilt anyway) and force people to simple, or all-js scripts (may be both a good practice, and maybe too restrictive in some cases)
  3. add and run gitinstalll on installing via git repo, install gitDependencies in that case ... adds new settings, but breaks no compatibility and solves the issue, my 2c
Copy link

@seishun seishun commented Nov 15, 2013

I agree. npm install with no args already runs the prepublish script for the same reason, so it would make sense to do the same for git urls.

Copy link

@mrjackdavis mrjackdavis commented Feb 19, 2014

I also agree. Repositories are for the source files, why should we have to add extra bulk (especially for larger packages)?
Since the idea of version control is to control the source, npm should assume that only the source is contained in a git repo and run prepublish when installing a package from git. It is theoretically identical to installing a package in a local directory.

joshprice pushed a commit to Tabcorp/stubby4node that referenced this issue Apr 23, 2014
npm doesn't run the prepublish task to compile the coffee when
installing from github urls (but does locally).

See npm/npm#3055
alfred-landrum pushed a commit to jut-io/node-oniguruma that referenced this issue Jul 10, 2014
Copy link

@cybertk cybertk commented Oct 6, 2014

Any updates?

Copy link

@denis-sokolov denis-sokolov commented Oct 6, 2014

npm has 861 open issues and is a bit behind at handling them. It will take a while to respond.

I personally would appreciate if I didn't get notifications about people inquiring about updates, but, alas.

natevw added a commit to natevw/node-hid that referenced this issue Oct 15, 2014
Copy link

@natevw natevw commented Oct 15, 2014

Yes, between this and #1876 I can't figure out any good way to use a forked module in dependent project, without publishing it to the public repo.

Backstory: I'm trying to get building for atom-shell on Windows. Somethings odd, and I'm trying to simplify how the build process works, but between these two issues there's not really a good way depend on git submodules in a non-published node module.

Copy link

@braco braco commented Dec 2, 2014

@natevw: try npm shrinkwrap, which is infuriating to use in the longer term, but can help with what you're describing.

Copy link

@natevw natevw commented Dec 4, 2014

@braco Thanks for documenting that, it is similar to what I ended up doing (which was to make a GitHub release tarball and install that instead).

Copy link

@john-kurkowski john-kurkowski commented Jan 16, 2015

By the time a Git URL's source code makes it to my node_modules, the repo's .npmignore has been applied.

the developer will make sure it works.

I don't get the full source from which to build. So I can't make sure it works. Not within package.json, anyway.

ursm added a commit to idobata/idobata-hooks that referenced this issue Jan 24, 2015
ursm added a commit to idobata/idobata-hooks that referenced this issue Jan 24, 2015
ursm added a commit to idobata/idobata-hooks that referenced this issue Mar 4, 2015
NoxHarmonium added a commit to agiledigital/react-dates that referenced this issue Jan 15, 2018
This will run when installing ‘react-dates’ directly from the git repo so that build artifacts are available. This is useful when testing.

- npm/npm#3055 (comment)
Copy link

@shellscape shellscape commented Jan 15, 2018

FWIW prepare doesn't appear to execute when installing a git dependency from a branch on npm@latest

Copy link

@strugee strugee commented Jan 16, 2018

@shellscape file a new bug and provide detailed environment details/steps to reproduce

jupereira0920 added a commit to jupereira0920/angular2-qrscanner that referenced this issue Jan 23, 2018
npm@5.0.0 now uses prepare instead of prepublish
Related issue npm/npm#3055

I keep both, to test first.
manuelvillar added a commit to manuelvillar/react-remarkable that referenced this issue Feb 23, 2018
Related issue npm/npm#3055
manuelvillar added a commit to manuelvillar/react-remarkable that referenced this issue Feb 23, 2018
mcmillhj-wta added a commit to willowtreeapps/react-digraph that referenced this issue Apr 4, 2018
When installing with NPM via a github URL, the prepublish hook is not run: npm/npm#3055. The workaround for this is to add a preinstall step that in turn calls the prepublish step.
ltetzlaff added a commit to ltetzlaff/pdf.js that referenced this issue Apr 24, 2018
ltetzlaff added a commit to ltetzlaff/pdf.js that referenced this issue Apr 24, 2018
vith added a commit to vith/uppy that referenced this issue May 22, 2018
When a prepare script is defined, npm and yarn will build uppy
automatically if it's being depended on through a git URL.
This is useful when downstream projects don't want to wait for
the next release to be tagged.

See npm/npm#3055 (comment)
See also yarnpkg/yarn#3553
thinkh added a commit to Caleydo/lineupjs that referenced this issue Jun 12, 2018
Adding the `prepare` script allows to install this repo from git uri:
`npm install --save git+`

For more information see:

* npm/npm#3055
* Example: tasti/react-linkify#61
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.