Cake.Npm on wsl ubuntu requires sudo? #3064
Replies: 3 comments 9 replies
-
To answer your question with any certainty, I'd have to get a look at the diagnostic-log of your Cake run. The "problem" is, that on my wsl, Cake.Npm detects The root cause of that problem is that I have npm installed in the normal (i.e. non-wsl) windows and that it is available in For elevated access the You could verify that your "problem" is the same as mine, by appending For me, as normal user there is one part:
For me, running in
and compare that to nils@pc$ which npm.cmd
/mnt/c/Program Files/nodejs//npm.cmd
nils@pc$ which npm
/usr/bin/npm To fix the problem you could either uninstall node on windows, leaving only the wsl installation or you could modify |
Beta Was this translation helpful? Give feedback.
-
Another option, which I prefer, is to configure your distro via [interop]
enabled = true
appendWindowsPath = false You can still call Windows executables using a fully qualified path, or define an alias for convenience if used often. |
Beta Was this translation helpful? Give feedback.
-
Though I like the solution provided by @gitfool best, there is one other alternative: Task("Default")
.Does(() => {
var settings = new NpmRunScriptSettings {
ScriptName = "-version",
ToolPath = "/usr/bin/npm"
};
NpmRunScript(settings);
}); As to your question:
You could open an issue on Cake.Npm and ask whether it is possible to build a workaround for this, but I personally feel it's the standard settings of wsl which are at fault here. |
Beta Was this translation helpful? Give feedback.
-
I have a fairly recent and clean ubuntu instance on wsl, and after doing
dotnet new react
I was following the Getting Started docs from Cake, and dotnet part (building the project) works fine withdotnet cake
, but as soon as I wanted to include npm part of it, I got the following (not helpfull) error, even if trying to run justNpmVersion()
But after running
sudo dotnet tool restore
andsudo dotnet cake
it worked as expected. My question is basically why? Because ideally it should work without sudo. I know it might have nothing to do with cake itself, but maybe someone else had this issue.I have:
node --version
v15.5.0
npm --version
7.3.0
dotnet --version
5.0.101
Beta Was this translation helpful? Give feedback.
All reactions