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

[Feature]: Prefer user installed node version when available. #1202

Closed
james-prado opened this issue Jan 24, 2023 · 4 comments
Closed

[Feature]: Prefer user installed node version when available. #1202

james-prado opened this issue Jan 24, 2023 · 4 comments
Labels
Area: @shopify/cli @shopify/cli package issues Type: Enhancement New feature or request

Comments

@james-prado
Copy link

james-prado commented Jan 24, 2023

What area(s) will this request affect?

Function

What type of change do you want to see?

Substantial change to existing feature

Overview

Prefer valid user installed version of nodejs if available.

Motivation

Switching between projects sometimes requires using different versions of nodejs. nvm makes switching versions much easier, but because Shopify CLI depends on node's homebrew formula I can no longer switch versions when moving between projects.

Nvm isn't compatible with node's homebrew formula. It'll always prioritize the homebrew formula which prevents any other installed node version from being used.

There is a work around, it requires moving all node versions installed by nvm to the beginning of PATH. This isn't ideal though since these problems will still occur for anyone using the default "out of box" configuration of these tools.

# Dynamically add all node versions installed via nvm to beginning of PATH,
# to take precedence over any other node version
# (i.e. installed via brew install node or any formula dependencies)
for f in $HOME/.nvm/versions/node/*; do
	if [ -d "$f" ]; then
		PATH=$f/bin:$PATH
	fi
done
@james-prado james-prado added the Type: Enhancement New feature or request label Jan 24, 2023
@matteodepalo matteodepalo added the Area: @shopify/cli @shopify/cli package issues label Jan 25, 2023
@james-prado
Copy link
Author

I think it's also worth noting that the work around I described above isn't perfect. Other core functionality of nvm such as installing new node versions is still broken. It's only a temporary solution at best.

@matteodepalo
Copy link
Contributor

Hi @james-prado thank you for flagging this, I'll bring it up with the team.

@matteodepalo
Copy link
Contributor

@james-prado This seems to be a local setup issue as the node version picked up by your terminal environment is going to depend on how your binaries resolve. There isn't much we can do on our side to make it so nvm is picked up before homebrew by default.

@alex-lighthouse
Copy link

For anyone in this situation, I moved the snippet that nvm adds to the .zshrc or .bashrc at the end of the file instead of at the beginning so that nvm can init itself after brew is added to the path.

Ref.: The snippet that I'm referring to => https://github.com/nvm-sh/nvm#install--update-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/cli @shopify/cli package issues Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants