-1

I want to add NPM's dependency in Dockerfile like that:

RUN PATH="/node_modules/@zxc/pdm-node-builds/dist/bin/pdm-node-scripts.js:$PATH"
RUN export PATH

RUN echo $PATH

But it does not work, any other idea?

EDIT: My issue was I had:

RUN PATH="/node_modules/@zxc/pdm-node-builds/dist/bin/pdm-node-scripts.js:$PATH" 

where should be:

RUN PATH="node_modules/@zxc/pdm-node-builds/dist/bin/pdm-node-scripts.js:$PATH"
Tomasz Waszczyk
  • 2,680
  • 5
  • 35
  • 73

1 Answers1

1

Use the ENV instruction to set environment variables in a Dockerfile. You also don't need the export statement in this case.

ENV PATH="/node_modules/@zxc/pdm-node-builds/dist/bin/pdm-node-scripts.js:$PATH"
RUN echo $PATH

EDIT: If your script is called pdm-node-scripts.js and it's located in /node_modules/@zxc/pdm-node-builds/dist/bin, then you should be adding the directory i.e. /node_modules/@relayr/pdm-node-builds/dist/bin to PATH, not the executable itself.

Tomasz Waszczyk
  • 2,680
  • 5
  • 35
  • 73
Proyag
  • 2,132
  • 13
  • 26
  • But still I get "/bin/sh: ./pdm-node-scripts: not found" which means there is no such library in the PATH ;/ – Tomasz Waszczyk Apr 17 '19 at 14:12
  • 1
    That sounds like a different issue. If this `pdm-node-scripts` executable is in a directory in your `PATH`, then you shouldn't have `./` in front of it to execute it. If it's in your current working directory, then you need the `./` (and you don't need to add it to `PATH`) – Proyag Apr 17 '19 at 14:17
  • 1
    You might be adding the wrong thing to `PATH`. Check the edited answer. – Proyag Apr 17 '19 at 14:23
  • Yes, I agree. I know it. Fight to work it. – Tomasz Waszczyk Apr 17 '19 at 14:43