For one of my projects, I’m using Angular with a custom library called services
, which I share across several apps (all in a monorepo). I then link the built version of services
locally via npm link
, so it appears in package.json
as a dependency (this looks like "services": "file:dist/services"
).
However, when I tried consolidating the code and running it through CI, I kept running into an error when running $ npm install
:
#!/bin/bash -eo pipefail
npm install
npm WARN checkPermissions Missing write access to node_modules/services
npm ERR! path node_modules/services
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'node_modules/services'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/xxxxx-debug.log
Exited with code 254
Even if I created node_modules/services
before running $ npm install
, I would get the same error. Turns out that because "services"
is a locally installed module, npm
tries to create a symlink from node_modules/services
to dist/services
— which doesn’t exist in a clean CI container. Chicken-and-egg problem (can’t run $ ng build services
to populate dist/services
without having the other NPM modules installed). So I actually had to create dist/services
manually before running $ npm install
. Oops!