it looks like the best way to install an npm package is to use node2nix. Ideally, I would like to not clone the package, but here we are.
I cloned nbb-v0.29 and ran node2nix in the directory. then nix-build.
It almost works but I got this error
shrinking RPATHs of ELF executables and libraries in /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9
npm ERR! code ENOENT5minstall executeActionslTree0m
checking for references to /build/ in /nix/store/85j4na3mz5nkv080ybli0cyf3k6j2fiz-node-dependencies-nbb-0.2.9...
npm ERR! syscall chmod
npm ERR! path /nix/store/s7r1l7vl3hpa4m5a1z2rbnqx1iq92zmn-nbb-0.2.9/lib/node_modules/nbb/out/nbb_main.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/nix/store/s7r1l7vl3hpa4m5a1z2rbnqx1iq92zmn-nbb-0.2.9/lib/node_modules/nbb/out/nbb_main.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
the symlink /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9/bin is broken, it points to /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9/lib/node_modules/.bin (which is missing)
rewriting symlink /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9/bin to be relative to /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9
patching script interpreter paths in /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9
checking for references to /build/ in /nix/store/4v6ndh0xn9m6dhnly83h66hgg81y0vip-node-dependencies-nbb-0.2.9...
building '/nix/store/h73y8iddw35zwkqk60wd1ny5c27vxksx-node-shell-nbb-0.2.9.drv'...
npm ERR! A complete log of this run can be found in:
npm ERR! /build/.npm/_logs/2022-03-20T20_18_16_555Z-debug.log
Not sure how to solve that particular issue, however depending on your goal here you could just use Nix to provide a dev shell with Node, then install Node packages normally (not using node2nix).
If you still want your NPM package installed via Nix, is there any additional info in the /build/.npm/_logs/2022-03-20T20_18_16_555Z-debug.log file?
It’s a bit confusing since there are a few layers here, the path with /build is spit out by NPM, but you also need the path from nix, see the note: keeping build directory line.
So looks like the log should be in /tmp/nix-build-nbb-0.2.9.drv-1/.npm/_logs.
No idea what all the silly stuff is, but looking at nbb it’s not really an npm package. It just has a package.json. See here.
The binary it’s trying to link here does indeed not exist. As-is, the package.json doesn’t do anything, except link a nonexistent file. The way this is packaged is apparently to first run bb on the repository, which produces the out directory, and then to run an npm publish that uploads artifacts that don’t even exist in the source.
It’s… Something. I’m sure there are better ways to actually hook build commands into your package.json, but the project isn’t doing that. I’ve never packaged anything with bb, so I can’t help untangle the build, but it clearly manages everything from dependencies to building the software, so node2nix won’t do anything for you here.