Fix #4628: npm install to a wrong location (#6742)

By default `npm install` will walk up the folder tree checking for a
folder that contains either a package.json file, or a node_modules
folder. If such a thing is found, then that is treated as the effective
"current directory" for the purpose of running npm commands.
This caused npm dependencies for language servers sometimes to be
installed in the wrong folder, described in #4628.
Adding `--prefix ./` to `npm install` forces
node_runtime.npm_install_packages to install packages in provided path
even if node_modules dir exists somewhere up the filesystem tree from
installation path.
This commit is contained in:
Julia 2024-01-28 14:10:10 -05:00 committed by GitHub
commit 8e523d812f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -166,6 +166,7 @@ impl NodeRuntime for RealNodeRuntime {
if let Some(directory) = directory {
command.current_dir(directory);
command.args(["--prefix".into(), directory.to_path_buf()]);
}
command.output().await.map_err(|e| anyhow!("{e}"))