Problems building node scaffolded plan

I am trying to build a node plan (it used to work) using the node scaffolding

It is using core/node and npm

It fails during npm install
screener: Detected build is occuring inside a git work tree.
screener: Setting NODE_ENV=development
screener: Building
screener: Installing dependencies using npm 5.6.0
'/usr/bin/env' -> '/hab/pkgs/core/coreutils/8.29/20180608092141/bin/env'
'package.json' -> '/hab/cache/src/screener-0.1.0/package.json'

grpc@1.12.4 install /hab/cache/src/screener-0.1.0/node_modules/grpc
node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/hab/cache/src/screener-0.1.0/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node" is installed via remote
added 495 packages in 24.602s
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.10.0
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: minimatch@3.0.4, required by ignore-walk@3.0.1
npm ERR! missing: brace-expansion@1.1.11, required by minimatch@3.0.4
npm ERR! missing: balanced-match@1.0.0, required by brace-expansion@1.1.11
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.11
npm ERR! missing: console-control-strings@1.1.0, required by npmlog@4.1.2
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.1, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.1, required by string_decoder@1.1.1
npm ERR! missing: console-control-strings@1.1.0, required by gauge@2.7.4
npm ERR! missing: string-width@1.0.2, required by gauge@2.7.4
npm ERR! missing: strip-ansi@3.0.1, required by gauge@2.7.4
npm ERR! missing: code-point-at@1.1.0, required by string-width@1.0.2
npm ERR! missing: is-fullwidth-code-point@1.0.0, required by string-width@1.0.2
npm ERR! missing: strip-ansi@3.0.1, required by string-width@1.0.2
npm ERR! missing: number-is-nan@1.0.1, required by is-fullwidth-code-point@1.0.0
npm ERR! missing: ansi-regex@2.1.1, required by strip-ansi@3.0.1
npm ERR! missing: string-width@1.0.2, required by wide-align@1.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: minipass@2.2.4, required by tar@4.4.1
npm ERR! missing: mkdirp@0.5.1, required by tar@4.4.1
npm ERR! missing: safe-buffer@5.1.1, required by tar@4.4.1
npm ERR! missing: yallist@3.0.2, required by tar@4.4.1
npm ERR! missing: minipass@2.2.4, required by fs-minipass@1.2.5
npm ERR! missing: safe-buffer@5.1.1, required by minipass@2.2.4
npm ERR! missing: yallist@3.0.2, required by minipass@2.2.4
npm ERR! missing: minipass@2.2.4, required by minizlib@1.1.0

If I manually cd /hab/cache/src/screener-0.1.0 and hab pkg binlink core/git && hab pkg binlink core/node
then npm install it works

Must be some native dependency not being found or linked?
EDIT This comes from the npm list --json call, not npm install

@nellshamrell might have some insights on this one.

Figured this out. There seems to be a bug in NPM 5.6

So it wasn't the npm install causing the problem it was the npm list command looking at optional dependencies and complaining

My fix / workaround is to override my do_build (if you already have a .npmrc you'd have to make yours smarter)

do_build() {

  # Becuase of a bug that's been in NPM for a while
  # where `npm list` will error because optional dependencies
  # are not installed :(
  # we set this here and then when do_default_build runs
  # it will get this setting and everything will be fine
  # https://github.com/npm/npm/issues/19393
  echo "optional=false" > "$CACHE_PATH/.npmrc"
  do_default_build
}

@raskchanky @nellshamrell I'm mentioning you in case you planned to look into this more I don't want you to waste your time.

Thanks

2 Likes