quokka icon indicating copy to clipboard operation
quokka copied to clipboard

Fully support nvm

Open chrisblossom opened this issue 6 years ago • 8 comments

Issue description or question

As I understand it, nvm is only supported via explicit configuration. This can cause obvious issues when changing/removing node versions with nvm. In my opinion, nvm and other node version managers should work without configuration. I think something like sindresorhus/run-node could be used to solve this.

OS name and version

OSX 10.13.6

chrisblossom avatar Sep 01 '18 20:09 chrisblossom

Thanks for sharing run-node, will investigate if we can use it.

This can cause obvious issues when changing/removing node versions with nvm.

This can be used as a version change resistant way for nvm specifically to always use current nvm node version:

"node": "~/.nvm/current/bin/node"

ArtemGovorov avatar Sep 03 '18 00:09 ArtemGovorov

I thought they removed the current symlink, but it looks like it just isn't enabled by default.

nvm use will not, by default, create a "current" symlink. Set $NVM_SYMLINK_CURRENT to "true" to enable this behavior, which is sometimes useful for IDEs. Note that using nvm in multiple shell tabs with this environment variable enabled can cause race conditions.

chrisblossom avatar Sep 04 '18 23:09 chrisblossom

I think the best way to support nvm would be to allow this bash substitutions in the config, this works in bash

{
  "node": "$(nvm which current)"
}

if you allow that and also add it to your documentation here https://quokkajs.com/docs/configuration.html#nodejs-version it would be a quick and easy change for users

odama626 avatar May 20 '21 18:05 odama626

I think the best way to support nvm would be to allow this bash substitutions in the config, this works in bash

Unfortunately we support multiple operating systems and bash isn't common to all operating systems so this syntax isn't an option. By default, if node is in your system path (note this is different from path being added when you start your shell) then you should not need to specify the node path at all and Quokka will automatically use the current version of node specified using nvm. Alternatively, you may try using the $NVM_SYMLINK_CURRENT option mentioned above and then use the symlink created by nvm.

smcenlly avatar May 20 '21 22:05 smcenlly

Just solved this for myself in Ubuntu bash shell. Have written it down what i did in this gist below after a bit of reading here and other places.Maybe it can help someone.

https://gist.github.com/madhu-sagar/570de73ff6949f33d9d40374fe184c7b

madhu-sagar avatar May 28 '21 19:05 madhu-sagar

Please add support for nvm-windows :(

vicenciomf2 avatar Feb 17 '24 13:02 vicenciomf2

Thanks for sharing run-node, will investigate if we can use it.

This can cause obvious issues when changing/removing node versions with nvm.

This can be used as a version change resistant way for nvm specifically to always use current nvm node version:

"node": "~/.nvm/current/bin/node"

I'm just giving this a try (after doing similar for Wallaby). I appreciate the config is slightly different using the key node and I've put it within ~/.quokka instead. However I can't seem to get it to pick this setting up, constantly complaining about Node being unavailable. Is there anyway I can debug this? The same value works fine in Wallaby.

{
    "node": "/Users/ian/.nvm/versions/node/v20.11.1/bin/node"
}

IPWright83 avatar May 03 '24 10:05 IPWright83

@IPWright83 - the configuration file for Quokka should be ~/.quokka/config.json.

If you are using Quokka PRO, it should look like this:

{
  "node": "/Users/ian/.nvm/versions/node/v20.11.1/bin/node",
  "pro": true
}

If you are using Quokka Community, it should look like this:

{
  "node": "/Users/ian/.nvm/versions/node/v20.11.1/bin/node",
  "pro": false
}

smcenlly avatar May 03 '24 22:05 smcenlly