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

NPM postinstall hooks not run with npm 5.3.0 #47

Closed
Jwashton opened this issue Jul 23, 2017 · 14 comments
Closed

NPM postinstall hooks not run with npm 5.3.0 #47

Jwashton opened this issue Jul 23, 2017 · 14 comments

Comments

@Jwashton
Copy link

As tested on two Ubuntu boxes and a Mac:

$ npm --version
5.3.0
$ npm install -g create-elm-app
# ... runs but doesn't call the postinstall hooks to create the shim
$ asdf global nodejs 8.1.2
$ npm --version
5.2.0
$ npm install -g create-elm-app
# ... runs and creates the shim as expected.
@4ndv
Copy link

4ndv commented Jul 26, 2017

Same problem with npm 5.1.0 and 5.2.0:

~ npm i -g coffeescript
/Users/noir/.asdf/installs/nodejs/8.1.2/.npm/bin/coffee -> /Users/noir/.asdf/installs/nodejs/8.1.2/.npm/lib/node_modules/coffeescript/bin/coffee
/Users/noir/.asdf/installs/nodejs/8.1.2/.npm/bin/cake -> /Users/noir/.asdf/installs/nodejs/8.1.2/.npm/lib/node_modules/coffeescript/bin/cake
+ [email protected]
updated 1 package in 1.352s
▲ ~ coffee
zsh: command not found: coffee

But with 5.0.4 everything is ok

@caleb
Copy link

caleb commented Aug 1, 2017

For now you can fix this by manually shimming: asdf shim nodejs .npm/bin/ember.

@ccblaisdell
Copy link

I had this issue and I wasn't entirely sure how to use @caleb 's fix. Based on what he provided I came up with the following:

~ ➜ asdf shim nodejs ~/.asdf/installs/nodejs/8.5.0/.npm/bin/ttab
~ ➜ asdf reshim nodejs 8.5.0

It didn't work after the first command, but it did after the second. I'm not entirely sure the first command was necessary, so ymmv.

@RobinClowers
Copy link

Yeah, same problem on macos. This is pretty annoying, any idea how we can fix this?

@caleb
Copy link

caleb commented Sep 14, 2017

I think the shims work in the newest version of this plugin... It doesn't use a post install hook anymore, so try upgrading to the newest version of the plugin: asdf plugin-update --all

This seems to have worked for me.

@zainfathoni
Copy link

I just upgraded the plugin to the newest version, but I still need to execute asdf reshim nodejs everytime I install npm package globally.

@caleb
Copy link

caleb commented Oct 13, 2017

@zainfathoni You are right, the automatic shimming is broken for me too.

edit: Try re-installing your nodejs... maybe you installed at a time when the npm postinstall hook wasn't installed on installation of a new node version...

It /seems/ to work for me when I wiped my nodejs versions and did a new asdf install nodejs 6.11.4, and then npm install -g babel-cli etc.

@zainfathoni
Copy link

Thanks for the suggestion @caleb, I will try it out later. 😄

@zainfathoni
Copy link

zainfathoni commented Oct 21, 2017

Hi @caleb , I already installed a new version of nodejs and tried to install vue-cli globally, but it still didn't shimmed correctly. So I still had to execute asdf reshim nodejs 8.7.0 again to make vue command available globally.

$ asdf install nodejs 8.7.0
$ asdf global nodejs 8.7.0
$ npm install -g vue-cli # vue command is not recognized yet
$ asdf reshim nodejs 8.7.0 # now vue command is recognized

Is it necessary to reinstall the asdf-nodejs plugin to make it works?

@caleb
Copy link

caleb commented Oct 30, 2017 via email

@sevenseacat
Copy link

sevenseacat commented Jan 9, 2018

I'm needing to manually re-shim after globally installing libraries too. I just set up asdf and asdf-nodejs today, and still seeing the behaviour.

@willbchang
Copy link

willbchang commented Oct 30, 2020

It still happens

~ node -v
v15.0.1
➜  ~ npm -v
7.0.3

➜  ~ which node
/Users/Will/.asdf/shims/node
➜  ~ which npm
/Users/Will/.asdf/shims/npm

➜  ~ npm i -g pnpm
added 1 package, and audited 1 package in 8s
➜  ~ pnpm
fish: Unknown command: pnpm

➜  ~ asdf reshim nodejs 
➜  ~ pnpm -v
5.10.2
➜  ~ which pnpm
/Users/Will/.asdf/shims/pnpm

@vaibhavsingh97
Copy link

As @willbchang said, it still happening for me too :(

@augustobmoura
Copy link
Member

This issue is solved on master now. The problem was on the npm side, it didn't fully support npm .hooks in these specific versions. I added a new mechanism for auto-reshimming that doesn't rely on node_modules/.hooks

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

10 participants