devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Init fails if npm is used from fnm

Open strowk opened this issue 1 year ago • 1 comments

What happened?

I had node installation using fnm on Windows. Windows PATH does not contain in this installation path to npm, as in this case used node version (and corresponding npm) vary depending on .node-version file, as it should be. Unfortunately this seems to break devspace, as running devspace init causes this:

Finishing installation of DevSpace CLI Running: node C:\Users\strow\AppData\Local\fnm_multishells\32200_1724002495600/node_modules/devspace/bin/..//index.js finish-install C:\Users\strow\AppData\Local\fnm_multishells\32200_1724002495600/node_modules/devspace/bin ################################################ WARNING: npm binary directory NOT in $PATH environment variable: C:\Users\strow\AppData\Roaming\fnm\node-versions\v20.16.0\installation\bin ################################################

What did you expect to happen instead?

Normal init results, no errors.

How can we reproduce the bug? (as minimally and precisely as possible)

Local Environment:

  • DevSpace Version: Cannot retrieve it, as devspace --version seems to be giving the same error
  • Operating System: Windows 11
  • ARCH of the OS: AMD64

Workaround

Adding path C:\Users\strow\AppData\Roaming\fnm\node-versions\v20.16.0\installation\bin to Windows system Path environment variable, seems to make it work, but it is not a good workaround, as it breaks the idea of how fnm is supposed to choose node version depending on .node-version file, hence is unusable in long term.

strowk avatar Aug 18 '24 17:08 strowk

Here is another workaround to avoid putting in the $PATH:

fnm exec --using=20 devspace

Of course, it depends on your default Node version. If you want to ease the command, you can create an alias:

alias devspace="fnm exec --using=20 devspace"

This way we can use the devspace command normally. 😎

erickmcarvalho avatar Oct 07 '24 04:10 erickmcarvalho