Hi All, I’m working on a CI pipeline and I want to get the affected libs with the handy one liner
npx nx print-affected which works great locally, however when I run this in a container I get the following error:
```docker run -it node:alpine sh
/ # npx nx print-affected
sh: node-waf: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! email@example.com preinstall:
npm ERR! spawn ENOENT
npm ERR! Failed at the firstname.lastname@example.org preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/logs/2020-06-26T13_52_41_269Z-debug.log
Install for [ ‘nx@latest’ ] failed with code 1
/ # whoami
/ # npx cowsay “Hello”
npx: installed 10 in 2.695s
< Hello >
||—-w | || || / # ``` at the end I just check
npx cowsay works to verify
npx is happy.
Googling is turning up scant results for
node-waf: Permission denied so I’m a bit stumped
Gitlab, but this output is on my local machine, in an alpine docker container
Well i believe you’re missing your node_modules in the docket image, a straight alpine image will not have nx installed
true but isn’t the point of
npx that you don’t need to have node modules installed?
You’ll have to use a docker file to using alpine as your base image install what you need copy over your files and you’ll be good to go. Nope it just allows you to run your node modules lol
Also welcome to the community :grin:
Thanks for the welcome!
ah I think I’ve solved it!
npx doesn’t require
node_modules to be present, but it checks the node path first (looking for
nx ) and when it doesn’t find it, it goes to the npm registry to try find the right dependency. In my case, it was not finding it locally in the path, so it went looking for https://www.npmjs.com/package/nx, which is totally unrelated to NX.
what I actually need is
npx @nrwl/cli print-affected , which totally works
```➜ docker run -it node:alpine sh / # npx @nrwl/cli print-affected npx: installed 124 in 9.236s
> NX The current directory isn’t part of an Nx workspace.
To create a workspace run: npx create-nx-workspace@latest <workspace name>
> NX NOTE For more information please visit https://nx.dev/``` In actual CI, I will have the repo copied to the container, so this will work. (I’m doing some CI config generation in this stage, and the actual yarn install comes later in another container)