svanderburg / node2nix

Generate Nix expressions to build NPM packages
MIT License
527 stars 100 forks source link

Assumes `package.json` and `package-lock.json` are in the same directory #161

Open colehaus opened 4 years ago

colehaus commented 4 years ago

With an invocation (on version 1.7.0) like:

node2nix --development --nodejs-10 --input dir1/package.json --lock dir2/package-lock.json

args.src in the resulting node-packages.nix only seems to reflect the first directory with package.json. This can lead to strange issues when actually building the resultant derivations. The error I got was ENOTCACHED [...] ERR! request to https://registry.npmjs.org/viz.js failed: cache mode is 'only-if-cached' but no cached response available..

svanderburg commented 4 years ago

I'm not entirely sure if I understand your question. But one reason why the directory structure does not exactly match the package.json specifiers is because NPM 3.x and newer, "flatten" the directory structure in which dependencies are moved up as high as possible in the node_modules/ directory hierarchy.

Can you do a small comparison? There is also an option in node2nix to disable flattening (see node2nix --help)

Does that result in the same warnings?

Maybe the warning could also be a defect in my trickery that tries to bypass the NPM cache.