npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm isn't running prepare script for a github dependency

What I Wanted to Do

I have a private github project, with a prepare script that transpiles some JS sources using Babel, which I tried to add as a dependency to another project, by using npm install

According to the docs, prepare should run after install with a github dependency; that way, in the other project I don’t have to go into node_modules/private-project and run the build process by myself.

What Happened Instead

The prepare script never runs when installing the github dependency.

Reproduction Steps

Platform Info

$ npm --versions
{ 'npm-bug-client': '1.0.0',
  npm: '6.4.1',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.1',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11' }

$ node -p process.platform

Same issue. Did you find a solution?

Actually never mind – mistake my end.

My (dependency) project’s previous build script was building, archiving the built materials, then tidying up the build files. I removed generation of the archive but I hadn’t realized it was then deleting the files it had archived. I removed that line from the script and now I see that the prepare script must be running, because the built files exist in node_modules/my-dep

A red herring was no relevant output during npm install: the prepare script’s output is not emitted. Could this be throwing you off too?

I thought at one point the problem might be that dist (the output dir I was expecting to see) was in my .gitignore file. I added an empty .npmignore thinking that might be a remedy, since the docs say the .gitignore file is used in the absence of an .npmignore. But it turned out in the end this wasn’t a factor: I now have no .npmignore again and it’s working fine.

This problem still exists (Tested with Node 8, 10 & 12): Git dependencies get their devDependencies installed and apparently prepare is supposed to be run with it never is: installing devDeps and running prepare script

Seems this occurs when the dependency URL has commit-ish at the end.