-
Notifications
You must be signed in to change notification settings - Fork 295
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
node_modules/.bin/jest: line 16: exec: node: not found #741
Comments
I have similar behavior. My Error:
Worth mentioning that my Node is installed using NVM |
this extension spawns a child process with shell, per node.child_process document (https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options):
Chances are it's shell setup-related? It is on our wish list to pass custom shell... Until it is available, the workaround is probably to make sure the default shell above is setup accordingly... |
Worth mentioning that for my case, restarting VSCode, which was started automatically after I logged into my machine, fixed the issue. Try to open the developer tools and check for |
@carlos-algms restarting vscode worked for me too, but this problem still happens sometimes even when vscode wasn't opened automatically |
Hey guys, Same problem here, but Node is installed on Debian (WSL2 setup). I think in my case it cannot access node because it try to launch the process on the host system, instead of the context of VSC ... I don't think it's even fixable from the extension source code 🤔 |
Hello there ! Some updates regarding my problem : As I use WSL and NVM, I decided to try to create a symlink from It would mean that the problem isn't from WSL itself (I mean the fact that I use WSL in Windows isn't the problem), I think it's more due to the fact that when Jest invokes a shell to execute its commands, It do not invoke the shell as the user that openned VSCode. So your session's file |
I had the same error due to my path in VS Code not having my NVM node directory in it (thanks @carlos-algms for the suggestion to check the I fixed it by following these stackoverflow steps to make sure I had the correct path:
|
I have been running into this issue for several weeks on OSX. So far I have tried creating an entry in ~/.bash_profile which worked for a few days then stopped again. I tried using a symlink in /usr/local/bin which had a similar result. It seems to be a dice roll whether or not my test runner is going to work every time I restart VSCode. If the child process shell is going to remain a problem for NVM users can we get an entry in the troubleshooting section of the docs about it? I wouldn't mind typing something up but so far every solution has only been a temporary fix. Using the above command to run code from the command line seems to be working for now though Ideally I'd like to use my taskbar too. |
I remember they released the test explorer and this was working great for a week or so, then it stopped working, I thought it was intermittent, maybe my other window with workspaces was causing issues, or a recent change to our Now I cannot seem to get it to work at all and have even tried a vanilla configuration making my package.json scripts just The error I get in the output tab is: not-test onProcessExit: process exit with code=127, signal=undefined
see troubleshooting: https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting
/bin/sh: npm: command not found
/bin/sh: npm: command not found
Jest process "watch-tests" ended unexpectedly
see troubleshooting: https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting Whenever I see node or npm not found it means that my version manager is not bootstrapping properly. I coincidentally just ran through this with setting up Husky yesterday. I use When fixing Husky they have a . /usr/local/opt/asdf/libexec/asdf.sh I installed I imagine something similar needs to happen with this extension now as well. It's still super odd that it was working for a small period of time, and when it did the new test explorer was great. I wish it'd come back D: |
This issue is somewhat complicated due to there are many possible causes and also many ways they can be fixed. Let me first explain how we spawn the process, which, hopefully, will shed lights on the issues and solutions... how do we start the jest run process?It uses node child_process to spawn a jest process with a "non-interactive & non-login" shell, which basically mean it will inherit vscode process env(1) + maybe-shell-initialization(2) Note, the current implementation uses the default shells specified by the node child_process (however this will be customizable in the upcoming release):
1. How does vscode initialize the process env?You can read the first 3 paragraphs in this vscode doc. Basically depends on how you start vscode. It will do different things to try to make sure your environment is initialized with ".bashrc" or equivalent. However, sometimes this process might not succeed and you will end up in an incomplete environment, thus any subsequent jest process will be equally incomplete.
2. How does an "non-interactive & non-login" shell got initialized?Each shell might behave differently, you can read up on the following posts about how different types of shell starting types can impact the initialization:
It varied by shell. For example, by default, no initialization will occur unless you have Therefore, even the initial env is not complete as described above, the new shell spawned by the extension can still be correct if there is a proper initialization configured. However, if you decide to fix the env issue via this route, please note that adding initialization during each spawned shell might have performance overhead. More help on the way...We know it is frustrating... We are working on adding 2 new settings (in v4.2) that could hopefully make it easier to address this issue:
|
If I try to set my "Setup Jest Command" It returns:
|
Please keep in mind your command will be executed in the default shell (i.e. |
I think I was noticing if I opened from the command line it may work, or maybe it's opposite -- opening from the command line doesn't work. ie: |
it hepls for me thx |
Works for me! thanks :) |
It worked for me. Thanks! |
I'm a nix-shell user. The nix-shell command initialises a bash environment for interactive and non-interactive usage. Generally you launch a nix-shell to start a terminal environment to then run other tools. This works well for CLI tools since I start a nix-shell and then run a CLI tool or tools. Now the problem has always been that IDEs have always had their own environment setup. Now in vscode it has integrated terminal which allows me to run nix-shell inside and proceed. But what about extensions and the commands they run? They aren't aware of the nix-shell environment and they running whatever global environment IDEs are started in. The most common solution is to just run the IDE within the nix-shell. But this is not always a great solution especially given that I have multiple projects each with their own nix-shell configuration. If I start IDEs in each environment I don't get the UX of flowing between projects easily inside the IDE. What I'd like to have is the ability to use 1 global vscode session, but the ability to run commands (including extension commands like vscode jest) inside designated "subsessions" which keep the environment live. Ideally this can work across all extensions. Right now the vscode jest's customisation allows me to inject a |
I believe another issue is if you launch via |
The following in settings in the workspace settings i.e.
|
for people who landed here, this issue should be fixed in v5 pre-release, feel free to give it a spin and let us know how it works for you. Thanks. |
@connectdotz I can confirm without any file modification and just by trtying the pre-release the extension is enabled correctly :) thank you! (also, had this issue multiple times but if stuck do not hesitate to fully restart vscode... it seems a common issue with the Jest extension on MacOS) |
This one is working for me 🥰 my setting:
|
For those who are facing this issue with mise, all I needed was to add
And for context, I have added following line in my shell profile ( eval "$(mise activate zsh --shims)" |
I solved my problem on macos, changing this configuration from
Hope it can help others. |
Environment
vscode-jest version
:4.0.3
node -v
:14.17.3
npm -v
oryarn --version
:6.14.13
npm ls jest
ornpm ls react-scripts
(if you haven’t ejected):jest@27.0.6
node_modules/.bin/jest
{"watch": true, "onSave": "test-file", "onStartup": ["all-tests"]}
MacOS Big Sur
Prerequisite
npm run test
ornode_modules/.bin/jest
)npm test
orpnpm test
Steps to Reproduce
After reload VS Code window, vscode-jest don't auto run and stopped
Relevant Debug Info
Expected Behavior
vscode-jest auto run and launch all test
Actual Behavior
vscode-jest stop auto run
The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...
The text was updated successfully, but these errors were encountered: