0

Adding other packages to the package.json works well. However installing a local package which is a folder cannot.

Part of my Dockerfile is the following:

COPY package*.json ./
RUN npm cache clean --force
RUN rm -rf node_modules

COPY . .

RUN npm i
RUN npm i ./textwrap-pkg  // <--- it is well executed ! if I make a typo it would raise an error.

So as you can see the folder textwrap-pkg is well copied part of COPY . . (I also logged into the image and could see). What I cannot find, and which is the problem, is the folder of the package in node_modules inside the Docker image.

The dependency in package.json is fine as it works on the host machine:

"textwrap": "file:./textwrap-pkg"

note: I tried removing volumes and images like suggested.

Edit

After a bit of investigations, I found out the source of the problem!

node_modules# ls -l textwrap-wasm-demo

textwrap-wasm-demo -> ../textwrap/examples/wasm/pkg

Isn't this awesome? It's a link. I followed with this, now I have files well present but still it does not work!

halfer
  • 19,824
  • 17
  • 99
  • 186
BenGee23
  • 43
  • 6
  • Could you please share what's the build output? error? – Roberto Yoc May 14 '23 at 17:35
  • These is no issue in the build (Docker / npm i) process. It does not even raise an error (it does when I make a typo in the path, so). the error appears at runtime by Node when importing the dependency (because not installed correctly / not in node_modules) `Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/usr/src/app/node_modules/textwrap-wasm-demo/' imported from /usr/src/app/text.js` – BenGee23 May 14 '23 at 17:38
  • could you please add text.js file to the question description? – Roberto Yoc May 14 '23 at 18:02
  • there is nothing special in it? I'm just import the package with its name : `import { draw_wrapped_text, WasmOptions, WasmPenalties } from "textwrap-wasm-demo";` – BenGee23 May 14 '23 at 18:44
  • Could you clarify your solution? You've said that you found the source of the problem, but that it still does not work - I am not clear if you have solved your problem. If you have, would you write an answer proper below? – halfer May 24 '23 at 11:29

0 Answers0