wbyoung / avn

Automatic Version Switching for Node
MIT License
1.14k stars 54 forks source link

`avn setup` throws error `TypeError: cb.apply is not a function` #106

Open wangyizhuo opened 3 years ago

wangyizhuo commented 3 years ago

Please describe your issue clearly and also include all details below.

Details

Steps to reproduce

avn setup

Output

avn: profile already set up (~/.zshrc)
/Users/wyz/.nvm/versions/node/v12.19.0/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267
      if (cb) cb.apply(this, arguments)
                 ^

TypeError: cb.apply is not a function
    at /Users/wyz/.nvm/versions/node/v12.19.0/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267:18

nvm specific

wbyoung commented 3 years ago

See the discussion starting here: https://github.com/wbyoung/avn/issues/105#issuecomment-660847541

PR welcome.

redtux commented 3 years ago

I can confirm this critical bug on Ubuntu 20.04.1 LTS with avn 0.2.4 and nvm 0.37.0 (latest).

nvm use default --latest-npm
Now using node v14.15.0 (npm v6.14.8)
avn setup
avn: profile already set up (~/.bash_profile)
avn: profile already set up (~/.zshrc)
/home/redtux/.nvm/versions/node/v14.15.0/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267
      if (cb) cb.apply(this, arguments)
                 ^

TypeError: cb.apply is not a function
    at /home/redtux/.nvm/versions/node/v14.15.0/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267:18
    at FSReqCallback.oncomplete (fs.js:184:5)

With node v10.23.0 it works.

nvm use lts/dubnium --latest-npm
Now using node v10.23.0 (npm v6.14.8)
avn setup
avn: profile already set up (~/.zshrc)
avn: profile already set up (~/.bash_profile)
avn: configuration complete (~/.avnrc)kipping project config: /home/redtux/.npmrc. (matches userconfig)
avn-nvm: installation complete
avn-n: installation complete

PS: Not volunteering for a PR or patch, just for information. :heart:

andfaulkner commented 3 years ago

Any updates on this? I'm still getting this exact error now, running:

wbyoung commented 3 years ago

@andfaulkner I may have mentioned on other issues that I haven't really worked on this for quite some time. It'd actually be good to find someone interested in maintaining it. But at this point, no progress on this particular issue, but any PR would be welcome.

diegosanz commented 1 year ago

I'm using n and I fixed it with:

  1. cd ~/.avn
  2. n auto (this installed node v4.0)
  3. cd && rm -R ~/.avn
  4. npm install -g avn avn-nvm avn-n
  5. avn setup
  6. And now it should work
leemm commented 10 months ago

To get it working with nvm this is what I did.

avn requires nodejs v4 to run sensibly, this is key.

  1. cd ~/
  2. nvm install 4
  3. npm install -g avn avn-nvm avn-n
  4. avn setup
  5. nvm use default
  6. cd <your project directory>