add-node-modules-path
add-node-modules-path copied to clipboard
`npm bin` is removed in npm v9
Hello. I notice the npm bin command will be removed in [email protected] when reading the release note of [email protected].
This elisp package heavily depends on npm bin, so I worry the package will require some action in the future. Although, I have no good idea right now.
I hope this sharing will be of some help.
See also:
- https://github.com/npm/cli/pull/5459
npm v9 has been released and will be latest on Nov 9, according to the announcement.
I've found the following workaround via npm exec, though the way may be a bit hacky:
(setq add-node-modules-path-command "npm exec --package=npm@8 -- npm bin")
Hey! Thanks for sharing. I didn't notice this issue at all, sorry.
That is unfortunate that they removed this command.
Before using npm bin we used to recursively look for a node_modules folder, but that also had issues.
Maybe until we find something people can at least refer to your workaround.
The following workaround using npm root may be better:
(setq add-node-modules-path-command "echo \"$(npm root)/.bin\"")
EDIT: Though this is still tricky.
I used to be grateful for the workaround at https://github.com/codesuki/add-node-modules-path/issues/23#issuecomment-1312961383, but now it seems that I need to set the following I have to configure it as follows.
(setq add-node-modules-path-command '("echo \"$(npm root)/.bin\"")))
I have also been using the workaround @hyakt mentions and that works fine for me on Linux. It didn’t work well on Windows, though (because the default shell is CMD still). It would probably make sense to use some elisp to concatenation in the .bin.