Rider can't find Node that is installed with NVM
I am running Arch Linux. I have Node Version Manager (NVM) and I have Node 18.3.0 installed.
In my `.csproj` file I have the following:
<Target Name="CheckForNpm" BeforeTargets="NpmInstall">
<Exec Command="npm -v" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="You must install node and npm to build this project" />
</Target>
<Target Name="NpmInstall" BeforeTargets="ProcessCSS" Inputs="package.json" Outputs="$(NpmLastInstall) ">
<Exec Command="npm install" />
<Touch Files="$(NpmLastInstall)" AlwaysCreate="true" />
</Target>
<Target Name="ProcessCSS" BeforeTargets="Compile">
<Exec Command="npm run processcss" />
</Target>
This basically checks and ensures that `node` and `npm` are installed as these are necessary for the CSS processing.
When I try to build the project in Rider, I get the following error:
But, if I try to build the solution in my Terminal, all is good:
~/code/bejebeje.admin/src/WebUI feat/node-virtual-env-via-nvm ❯ dotnet build .
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.Determining projects to restore...
All projects are up-to-date for restore.
Domain -> /home/j/code/bejebeje.admin/src/Domain/bin/Debug/net6.0/bejebeje.admin.Domain.dll
Application -> /home/j/code/bejebeje.admin/src/Application/bin/Debug/net6.0/bejebeje.admin.Application.dll
Infrastructure -> /home/j/code/bejebeje.admin/src/Infrastructure/bin/Debug/net6.0/bejebeje.admin.Infrastructure.dll
8.11.0
> bejebeje.admin@1.0.0 processcss
> npx tailwindcss -i ./Styles/styles.css -o ./wwwroot/css/styles.css --minify
Done in 263ms.
WebUI -> /home/j/code/bejebeje.admin/src/WebUI/bin/Debug/net6.0/bejebeje.admin.WebUI.dllBuild succeeded.
0 Warning(s)
0 Error(s)Time Elapsed 00:00:04.45
~/code/bejebeje.admin/src/WebUI feat/node-virtual-env-via-nvm ❯
What must I do to get Rider to work and build my solution?
Please sign in to leave a comment.
Hello, could you please check if there are right paths to node and npm in Preferences | Languages & Frameworks | Node.js?
Thanks for the reply Olga Diakonova.
Yes I have the right paths set up:
And here is the path from the terminal:
Yet the build still fails :(
Any more ideas please? I still can't run via Rider.
I also have this same issue with Node installed through Homebrew. Rider preferences are happy with node and npm paths, and in my terminal both are runnable, but when I try to build I get the error
My Preferences show
I used below lines to solve the issue, run in terminal
Dyson did you run those commands in the Terminal that is within Rider?
I am working on a .NET project on Debian and have the same problem.
The node project can be started via terminal without any problems.
As soon as I start it in connection with .NET npm and Node are missing.
I was able to temporarily solve the problem for me by creating links from .nvm/versions/x/bin/[node|npm] to /usr/bin/[node|npm].
But this is far from ideal and I would really like a solution that works with .nvmrc.
Does anyone have a solution?
I also have this issue. For me this happens on Ubuntu 22.04 using Wayland. I'm using zsh. Everyting runs perfectly in terminal. Even terminal within Rider. However as soon as you press the debug or run button within Rider, it cannot find node.
I tried this but also did not work.
Permissions for Rider to find Node:
nano ~/.profile
Add this to the bottom:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm >
Dyson this did not work for me unfortunately. Really sad that Rider cannot get something simple like this to work. Or NO help from the rider team.
Hello,
It looks like you have faced a known issue https://youtrack.jetbrains.com/issue/RIDER-79717/Rider-2022.1.2-cannot-find-nvm-managed-nodejs-and-npm.
NVM installation changes a particular user environment (PATH and/or .bashrc). When Rider is launched from Toolbox app or via a desktop entry, it does not inherit user environment, that's why build targets can't execute npm or node - no valid path can be found in Rider environment. As a workaround I'd suggest launching Rider by executing <Rider installation folder>/bin/rider.sh with environment set up correctly for running node and npm.
Let me know if there is anything else I could help you with. Have a great day!
Why does Toolbox or Rider not inherit from the user environment? Surely this is the problem in the first place and should be fixed, rather than worked around?
What is the point of using Toolbox, or Rider, if we still have to run the /bin/rider.sh file?
I agree, this will likely be addressed in future versions of Rider. You can track the status of support for NVM in Rider here - https://youtrack.jetbrains.com/issue/RIDER-90115/Support-NVM-managed-environment-in-Rider. You can vote for the issue and subscribe for further updates in YouTrack.
Before it's implemented, you can use the workaround suggested above.
I have just setup a bran new laptop with Ubuntu 22.10.
No matter how I launch Rider, Node is not found! This is sop infuriating you have no idea. It's a complete blocker.
Running the rider.sh file make no difference.
HOW do I get projects to run and build with Rider?!?!?! How is this such an issue with no consistent fix?
Come on Ivan and Jetbrains.... Literally staring at my computer now unable to work.........
Thank you Ivan, I hope that the problem will soon be given a higher priority to be dealt with.
I would also like to note that classically, without nvm, everything runs flawlessly.
I have already described a working interim solution for nvm under Debian-based distributions.
Still, I look forward to an out-of-the-box nvm solution. ;-)
Dylan Let's take a look at why doesn't the workaround work for you on your new system. After you have set up your environment via NVM, have you restarted your shell instance or ran source ~/<your profile file> before launching rider.sh? NVM uses profile files (.bashrc, .bash_profile etc.) to update user shell env and for it to take effect after installation, you have to ensure that your profile script has been executed.
Brand new install of Ubuntu 22.04.
Installed nvm. nvm install 16. nvm use 16.
Install dotnet 7 sdk.
Install Rider 2023.2 from Toolbox (not flatpak).
Try run a solution that requires node and immediately get an error.
26>Website.Admin.csproj(62,5): Error : Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE.
26>------- Finished building project: Website.Admin. Succeeded: False. Errors: 1. Warnings: 23
Rider is identifying these node paths:
which node
/home/dylan/.nvm/versions/node/v16.20.2/bin/node
which npm
/home/dylan/.nvm/versions/node/v16.20.2/bin/npm
Everything works find from terminal.
This is incredibly frustrating that Rider does not work out the box. Now I need to spend a huge amount of time trying to fix this just to get working. And it's different on different distros.
WHAT can we do to get this working??
https://youtrack.jetbrains.com/issue/RIDER-79717/Rider-2022.1.2-cannot-find-nvm-managed-nodejs-and-npm
https://youtrack.jetbrains.com/issue/RIDER-90115/Support-NVM-managed-environment-in-Rider
https://youtrack.jetbrains.com/issue/IDEA-146037/Load-interactive-shell-environment-variables-on-Linux?s=Load-interactive-shell-environment-variables-on-Linux
Hello, Dylan,
Thank you for highlighting this issue. Please accept our apologies for the inconvenience caused by this behavior.
Fixing this problem is on our roadmap and we will definitely address it in the upcoming releases. Meanwhile, I would like to offer you to use one of the available workarounds, e.g.:
Manually launch Rider via
<Rider installation path>/bin/Rider.sh
script from a shell where all the NVM-related variables are availableEdit
~/.local/share/applications/jetbrains-rider.desktop
file to make sure that.bashrc
is executed and variables are available for Rider, e.g.Exec=/bin/bash -l -i -c “<Rider installation path>/bin/Rider.sh” %f
Please let me know if you have any additional questions, I’d be happy to help.
Thank you Ivan - will test. As a note, Rider is installed through Toolbox.
In that case path to Rider installation directory will be under ~/.local/share/JetBrains/Toolbox/apps
Please do let me know if the workarounds work for you.
Thanks Ivan,
the second workaround (modifying the desktop file) worked for me. It seems to be the better solution, as you can continue using Rider the usual way and don't have to launch it from command line.
FYI: The desktop file of the snap installation is located at:
/var/lib/snapd/desktop/applications/rider_rider.desktop
Michael's approach works.
But you need to do also:
nvm alias default <version>.
then reopen rider and it will use the nvm version of node