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

npm: command not found after vscode update #229071

Open
jpSimkins opened this issue Sep 19, 2024 · 0 comments
Open

npm: command not found after vscode update #229071

jpSimkins opened this issue Sep 19, 2024 · 0 comments
Assignees

Comments

@jpSimkins
Copy link

jpSimkins commented Sep 19, 2024

When running any NPM Script in vscode, I now get this:

Executing task: npm run npm-version 

/usr/bin/bash: line 1: npm: command not found

 *  The terminal process "/usr/bin/bash '-c', 'npm run npm-version'" failed to launch (exit code: 127). 

I can run this fine in vscode terminal:

$ npm run npm-version 

> @pcn/[email protected] npm-version
> npm --version

10.8.2

This worked fine a few weeks ago.

I updated vscode recently and now I cannot use the NPM Scripts.

I have node and npm installed using NVM.

I already tried fully removing node, npm and NVM. I even removed and reinstalled vscode but this issue still persists.

I use this script to install NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Then I run:

nvm install --lts
nvm use --lts

I even ran this as others online said this worked for them (years ago):

nvm alias default v20.17.0

Current version:

node --version
v20.17.0
$ npm --version
10.8.2

Which:

$ which npm
/home/jpsimkins/.nvm/versions/node/v20.17.0/bin/npm

.bashrc contains:

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 bash_completion

I even tested moving that snippet to .bash_profile with no change.

Since vscode was updated, NPM Scripts are broken.

I also tried installing older versions since when I run in bash I see this:

/usr/bin/bash npm --version
/home/jpsimkins/.nvm/versions/node/v20.17.0/bin/npm: npm: line 2: syntax error near unexpected token `'../lib/cli.js''
/home/jpsimkins/.nvm/versions/node/v20.17.0/bin/npm: npm: line 2: `require('../lib/cli.js')(process)'

I tried v18.20.4:

nvm install v18.20.4
nvm use v18.20.4
nvm alias default v18.20.4

Same issue.

Even v16.20.2:

nvm install v16.20.2
nvm use v16.20.2
nvm alias default v16.20.2

Same issue.

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.93.1
  • OS Version: Ubuntu 24.04.1 LTS

Steps to Reproduce:

  1. Have this working with a previous version of vscode
  2. Update to latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants