The location that npm link
tries to install symlinks into is inside of it's /nix
installation directory which is unwritable, and thus fails. Specifically, when trying to link a package named foo
, it tries to create a symlink at /nix/store/<nodejs-nix-package-hash>-nodejs-<nodejs-version>/lib/node_modules/foo
.
It should try writing (and reading) to somewhere else that's actually allowed to be written to.
Do npm link
inside a node.js package.
If you don't have a local node.js package:
nix-env -iA nixpkgs.nodejs
)npm init
to create a package.json.npm link
It is possible to make a workaround for this by having a custom prefix inside ~/.npmrc. So if you create ~/.npmrc with content:
prefix=~/.npm
Next time your run npm link or npm install -g, it would use ~/.npm as root folder.
It would be nice to incorporate this inside nodejs nix expression so it could use some global writable folder by default. I would take a closer look if we could have this in nodejs expression.
Most helpful comment
It is possible to make a workaround for this by having a custom prefix inside ~/.npmrc. So if you create ~/.npmrc with content:
Next time your run npm link or npm install -g, it would use ~/.npm as root folder.
It would be nice to incorporate this inside nodejs nix expression so it could use some global writable folder by default. I would take a closer look if we could have this in nodejs expression.