wbyoung / avn

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

Error loading plugins in node v12, prevents activation of correct node #95

Open percyhanna opened 4 years ago

percyhanna commented 4 years ago

I believe this is a bug in avn, but I'm not 100% certain.

It seems that Node v12 (or some other version) has changed the message format for the require exception message, such that this regex no longer works.

If the current version of Node is v12, the plugin loading code fails to run properly. If I switch to an older version, e.g. nvm use 8 and then try to cd into the directory, it works fine.

I will open a PR for a potential fix.

Details

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

Fatal Error: Cannot find module '/Users/percyhanna/.avn/plugins/avn-n'
Require stack:
- /Users/percyhanna/.avn/lib/plugins.js
- /Users/percyhanna/.avn/lib/hooks.js
- /Users/percyhanna/.avn/lib/avn.js
- /Users/percyhanna/.avn/index.js
- /Users/percyhanna/.avn/bin/_avn
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /Users/percyhanna/.avn/lib/plugins.js:59:20
    at tryCatcher (/Users/percyhanna/.avn/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/Users/percyhanna/.avn/node_modules/bluebird/js/release/reduce.js:168:18)
    at Object.gotAccum (/Users/percyhanna/.avn/node_modules/bluebird/js/release/reduce.js:155:25)
    at Object.tryCatcher (/Users/percyhanna/.avn/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/percyhanna/.avn/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/percyhanna/.avn/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/percyhanna/.avn/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/percyhanna/.avn/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/percyhanna/.avn/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/percyhanna/.avn/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/percyhanna/.avn/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/percyhanna/.avn/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

avn is loaded in my ~/.bash_profile} file with:

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

nvm specific

percyhanna commented 4 years ago

I didn't see anything that implied some local configuration or customization would have changed the exception message, but that is conceivable.

alpe88 commented 4 years ago

This is tied to #105 - there's also more information there. I am also experiencing this issue. Seems the first step is to update the polyfil dependency. This dependency is tied to npm I think. There's also a failed merge from dependabot from 20 days ago that tried updating npm.