add-node-modules-path icon indicating copy to clipboard operation
add-node-modules-path copied to clipboard

`npm bin` is removed in npm v9

Open ybiquitous opened this issue 3 years ago • 6 comments
trafficstars

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

ybiquitous avatar Sep 20 '22 05:09 ybiquitous

npm v9 has been released and will be latest on Nov 9, according to the announcement.

ybiquitous avatar Oct 25 '22 13:10 ybiquitous

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")

ybiquitous avatar Oct 25 '22 13:10 ybiquitous

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.

codesuki avatar Nov 14 '22 00:11 codesuki

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.

ybiquitous avatar Nov 14 '22 02:11 ybiquitous

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\"")))

hyakt avatar Jun 16 '23 12:06 hyakt

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.

zach-delong avatar Oct 28 '23 11:10 zach-delong