npm Community Forum (Archive)

The npm community forum has been discontinued.

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

Postinstall script runs before the `node_modules/.bin` is created

What I Wanted to Do

Removed the node_modules folder and decided to install the deps in package.json from scratch. My post install script has the following command:

"postinstall": "cross-env ..."

cross-env is listed under devDependencies:

"cross-env": "^5.1.3",

I run npm i, I get /bin/sh: cross-env: command not found. I check node_modules/.bin – no such folder.

I do the same move a few times, I trash node_modules, I run install, I remove post install script, I try again, no .bin, remove everything, run install again, now it works.

Great consistency. I can’t repro this anymore.

What Happened Instead

Reproduction Steps


Platform Info

$ npm --versions
npm --versions
  npm: '6.9.0',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  llhttp: '1.1.3',
  modules: '72',
  napi: '4',
  nghttp2: '1.38.0',
  node: '12.3.1',
  openssl: '1.1.1b',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.29.1',
  v8: '',
  zlib: '1.2.11'
$ node -p process.platform