mbolotov / intellij-cypress

IntelliJ-Cypress plugin: https://plugins.jetbrains.com/plugin/13819-intellij-cypress Pro version: https://plugins.jetbrains.com/plugin/13987-cypress-support-pro
MIT License
35 stars 5 forks source link

/usr/bin/env: ‘node’: No such file or directory #101

Open Jamesking56 opened 1 year ago

Jamesking56 commented 1 year ago

When I run Cypress inside of PHPStorm to run all tests inside of a directory, I get:

/usr/bin/env: ‘node’: No such file or directory

Node is definitely present, as cypress runs fine normally in the terminal. I've checked the run configuration and it all points to the correct Node paths...

Any ideas what else I can check here?

I'm running PHPStorm 2022.2 on PopOS 22.04

mbolotov commented 1 year ago

Hi James, Do you mean that the problem is only present for the 'all tests inside of a directory' mode? Can you post the entire first line of the console output (the one with start command)?

Jamesking56 commented 1 year ago

@mbolotov Yes exactly, here is the output in PHPStorm's test window (had to censor the project name as its confidential):

/home/jamesking56/.nvm/versions/node/v16.16.0/bin/npx cypress run --reporter /tmp/intellij-cypress-reporter12805111157771413441.js --spec /home/jamesking56/PhpstormProjects/{censored}/tests/cypress/**/*
/usr/bin/env: ‘node’: No such file or directory
mbolotov commented 1 year ago

can you also provide the command for a single test which is working okay? what's the difference?

Jamesking56 commented 1 year ago

Single tests aren't working OK and are showing the same error

mbolotov commented 1 year ago

It's a bit hard to reproduce the problem as I'm on Windows mostly of the time. So you mean when you run this command directly in terminal, it working okay?

cd /home/jamesking56/PhpstormProjects
npx cypress run  --spec /home/jamesking56/PhpstormProjects/{censored}/tests/cypress/**/*

Also, you could try creating a symlink as described here: https://stackoverflow.com/questions/26320901/cannot-install-nodejs-usr-bin-env-node-no-such-file-or-directory

Jamesking56 commented 1 year ago

Yes that command works in the terminal as normal and I've added the symlink and it does not fix the issue

mbolotov commented 1 year ago

this might be related to the user under you run PHPStorm itself. is it the same user as the one use in terminal?

Jamesking56 commented 1 year ago

Yes it is the same user, installed via Jetbrains Toolbox

mbolotov commented 1 year ago

you can also play with the settings on runner tab: image if you clear the Package Manager field, you'll be able to select and use a NodeJS interpreter directly.

Threnos commented 1 year ago

Today I faced this as well. It was working for quite a while until today when I updated node via nvm from 16.14.2 to 16.17.0. Clicking "Run all tests in cypress" opens runner window where it is clearly seen that old node version is chosen (that was deleted after an update) image Specifying correct paths to node lead to runner starting with error just like topicstarter reported.

Webstorm correctly identified new node version image

Everything else works with new node as expected without any issues. I tried restarting webstorm, clearing it's cache, completely reinstalling plugin.

WebStorm 2022.2.1 Build #WS-222.3739.57, built on August 16, 2022 Runtime version: 17.0.3+7-b469.37 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.15.0-46-generic GC: G1 Young Generation, G1 Old Generation Memory: 1926M Cores: 16 Non-Bundled Plugins: net.vektah.codeglance2 (1.5.5) me.mbolotov.cypress (1.5) Current Desktop: X-Cinnamon

list4c commented 1 year ago

I have the same issue, also using nvm and linux. Tried running a single test but it failed.

UPDATE: I worked around the problem by installing a new version of node using Snap Store (I'm on Ubuntu). So maybe the problem is handling of node versions installed via nvm ?

jippeholwerda commented 1 year ago

This is due to the fact that from where PHPStorm/Webstorm is started, the correct terminal config / env vars are not present. When starting PHPStorm/Webstorm from the terminal it probably works. See https://youtrack.jetbrains.com/issue/IDEABKL-7589