wbyoung/avn

Cannot find module

verpixelt opened this issue ยท 15 comments

On node 14.5.0 when trying to switch to a folder with a .node-version folder the app throws the following error: Fatal Error: Cannot find module '/Users/verpixelt/.avn/plugins/avn-nvm'
Details

  • avn avn 0.2.4
  • node node 14.5.0
  • n n 6.5.1
  • zsh zsh 5.7.1

The output of __avn_debug in the directory with a .node-version file is:

Fatal Error: Cannot find module '/Users/verpixelt/.avn/plugins/avn-nvm'.
Require stack:
- /Users/verpixelt/.avn/lib/plugins.js
- /Users/verpixelt/.avn/lib/hooks.js
- /Users/verpixelt/.avn/lib/avn.js
- /Users/verpixelt/.avn/index.js
- /Users/verpixelt/.avn/bin/_avn

avn is loaded in my ~/.{bash|zsh}{_profile|rc} file with:

`[[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn`

Does /Users/verpixelt/.avn/plugins/avn-nvm look like a module?

There are no plugins inside the folder.

Looks like you should try reinstalling.

rm -R ~/.avn

Then install.

This is what happens during setup:

avn setup
avn: profile setup complete (~/.zshrc)
avn: restart your terminal to start using avn
/usr/local/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 /usr/local/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267:18
    at FSReqCallback.oncomplete (fs.js:177:5)

That seems quite strange. Did that happen before when you ran the setup as well?

This is the type of thing I'd expect all users to experience if it wasn't something unique to your environment.

Any chance you can work on tracking down where the issue is coming from within avn?

Without more detail, I'm going to be honest, I doubt I'd be able to come up with a solution.

Thanks for your reply, @wbyoung. I've tried a few more things including switching from the latest node version at the time 14.5.0, to something lower. In my case I ran your avn setup with 10.0.0 and it worked ๐ŸŽ‰
So I thought the node version might have been corrupted, removed it, re-installed 14.5.0 and it failed again, with the same error as posted above.

cb.apply is part of the polyfill.js in graceful-fs. Not sure tho why this would throw an error in my specific case. I've tried a fresh install on another machine. macOS 10.15.5, fresh n install, fresh node 14.5.0, same error on running avn setup.

Ok, could be part of a dependency issue and comparability. Perhaps upgrading all of the dependencies of the project would fix it.

I don't do much coding these days. If you want to give that a try, go for it & let me know or submit a PR.

Avn correct installed with node version 10.0.0
When i first installed Avn i used node version 14.6.0 and getting error, this error i gen and with node version 12.18.3
`/Users/usename/.nvm/versions/node/v12.18.3/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/usename/.nvm/versions/node/v12.18.3/lib/node_modules/avn/node_modules/npm/node_modules/graceful-fs/polyfills.js:267:18
at FSReqCallback.oncomplete (fs.js:169:5)`

+1

Setting up a new mac today. First tried to install with Node@12 and got the exact same thing as @lobanovkirill. Switched to Node@10 and it worked.

Thanks for confirming, @tybro0103.

PR welcome.

Closing this in favor of #106 which better represents the issue that @verpixelt had after reinstall.

I ran into the same issue when updating from node 10.13.0 to 14.15.1 using nvm

~ $ cd dev/web-pathfinder
Fatal Error: Cannot find module '/Users/konstantintieber/.avn/plugins/avn-n'
Require stack:
- /Users/konstantintieber/.avn/lib/plugins.js
- /Users/konstantintieber/.avn/lib/hooks.js
- /Users/konstantintieber/.avn/lib/avn.js
- /Users/konstantintieber/.avn/index.js
- /Users/konstantintieber/.avn/bin/_avn

Fixed it as suggested by @wbyoung with:

rm -R ~/.avn
nvm exec 10.13.0 npm install -g avn avn-nvm avn-n
nvm exec 10.13.0 avn setup

EDIT: if you do not have the node 10 version installed yet, you have to run nvm install 10.13.0 before executing the commands above

Thanks @konstantintieber. It worked

This seems to have stopped working for node 16, I keep getting the same TypeError again

@cko-jimmy-wong see/comment on #106, but please note the last comment in there about the lack of attention this project gets.