Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to perform npm operations with a symlinked node_modules #52

Open
dnr opened this issue Feb 12, 2021 · 2 comments
Open

document how to perform npm operations with a symlinked node_modules #52

dnr opened this issue Feb 12, 2021 · 2 comments

Comments

@dnr
Copy link

dnr commented Feb 12, 2021

Is your feature request related to a problem? Please describe.

I'm using a symlinked node_modules by calling npmlock2nix in my shell.nix, so that my interactive processes use the exact same files as my build. At some point I'd like to run npm update on some of my dependencies. When I do this, npm rightfully complains with npm WARN checkPermissions Missing write access to /my/project/node_modules/...

The npm install man page describes the --package-lock-only flag, which sounds like it should do what I want, but it doesn't actually work. In any case, npm update doesn't have that flag.

As a workaround, I suppose that a workaround might be: copying node_modules to the current directory, running npm, and then deleting it and letting npmlock2nix rebuild a node_modules in the nix store and create a symlink to it. That seems pretty annoying, though.

Describe the solution you'd like

Document the intended way to use npm commands that modify package.json or package-lock.json when using a symlinked node_modules.

If this requires some work on the npm side, is there a feature request filed there? Does yarn or another alternative npm implementation have a "resolve only, don't install" mode?

@andir
Copy link
Collaborator

andir commented May 31, 2021

I don't think that updating dependencies with symlinked node_modules is currently possible for all the reasons you've mentioned. There in no feature request on the NPM side just yet as I haven't really spent much time on this project (it does work for my initial requirements, switched employers, ...). If you can open one that would be great.

@dnr
Copy link
Author

dnr commented Jun 21, 2021

I dug around in the npm issues to see if this had been filed already, and was just about to file it when I found npm/cli#3408, which makes this work (or documents a previous change that made it work). With that, I was able to install and update using --package-lock-only with no errors about not being able to write to node_modules.

So probably all that has to be done is update the docs to say use npm version >= 7.18.0 and add --package-lock-only to npm install + update commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants