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

zsh: command not found "npm" #1065

Open
RigottiG opened this issue Sep 12, 2023 · 3 comments
Open

zsh: command not found "npm" #1065

RigottiG opened this issue Sep 12, 2023 · 3 comments

Comments

@RigottiG
Copy link

RigottiG commented Sep 12, 2023

Environment

  1. vscode-jest version: 6.0.1
  2. node -v: 18.12.1
  3. npm -v or yarn --version: 8.19.2
  4. npm ls jest: [email protected]
  5. your vscode-jest settings if customized:
    • jest.autoRun? "off"
  6. Operating system: Linux Manjaro

Prerequisite

  • are you able to run jest test from the command line? Yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) npm run test

Steps to Reproduce

Just create a minimal project and add Jest and the vscode-jest extension and I got an error.

If I run code . inside a terminal, the extension works fine.

Expected Behavior

Run vscode extension

Actual Behavior

Jest (clean-react)

[info] auto config:

found:
  rootPath: /home/guilherme/Development/clean-react
  jestCommandLine: npm test --


[warn] possible process env issue detected, restarting with a login-shell...


zsh: command not found: npm


[error] failed to retrieve test file list. TestExplorer might show incomplete test items

[info] jest process failed to start, most likely due to env or project configuration issues, please see: https://github.com/jest-community/vscode-jest/blob/master/README.md#jest-failed-to-run

@connectdotz
Copy link
Collaborator

Hmm, this sounded like a typical shell env issue. Usually fixed by restarting with a login shell... Do you happen to have jest.shell configured? If you are using zsh, try to set it to zsh to see if that makes any difference. Does this happen every time you start vscode? Or only when vscode got updated, i.e. one time thing?

@RigottiG
Copy link
Author

Hmm, this sounded like a typical shell env issue. Usually fixed by restarting with a login shell... Do you happen to have jest.shell configured? If you are using zsh, try to set it to zsh to see if that makes any difference. Does this happen every time you start vscode? Or only when vscode got updated, i.e. one time thing?

I have these configuration.

  "jest.shell": "zsh",
  "jest.autoRun": "off",

but always I open my vscode I got this issue.

@connectdotz
Copy link
Collaborator

Where do you set the PATH?

zsh has different setup files between login and interactive shells... if the env is set in the interactive shell mode (zshrc) then even using login shell will not source it. While you can try to make the shell login and interactive (by passing -l -i), but I think the right solution might be either to move the critical env setup to the zshenv file or otherwise manually source the zshrc before jest (either in your test script or jestCommandLine setting)

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