volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
11.15k stars 238 forks source link

Node is not available when running npx command #1434

Open hadasgazit opened 1 year ago

hadasgazit commented 1 year ago

I'm trying to install storybook, using npx in a project using volta. I'm getting the error "Node is not available"

when running VOLTA_LOGLEVEL=debug I'm getting: [verbose] Found default configuration at '/home/hadasg/.volta/tools/user/platform.json' [verbose] node@16.13.1 has already been fetched, skipping download [verbose] yarn@1.22.17 has already been fetched, skipping download [verbose] Active Image: Node: 16.13.1 from project configuration npm: 8.1.2 from project configuration pnpm: None Yarn: 1.22.17 from project configuration [verbose] Could not find Volta-managed platform, delegating to system Volta error: Node is not available.

To run any Node command, first set a default version using volta install node [verbose] Error cause: No such file or directory (os error 2) Error details written to /home/hadasg/.volta/log/volta-error-2023-01-29_19_19_51.390.log [verbose] No custom hooks found [verbose] No custom hooks found

volta version is 1.1.1 (although it also happened with version 1.0.5)

mufasa71 commented 1 year ago

Can you provide simple reproducible example?

hadasgazit commented 1 year ago

for me it was just running in cmd: npx storybook init

(I'm using ubuntu)

mufasa71 commented 1 year ago

Can you try running volta install node ?

charlespierce commented 1 year ago

Hi @hadasgazit, that's very strange! It's not obvious from the debug log what exactly is going on. What appears to be happening is that Volta is finding the expected Node version, launching that, and then something in that script is trying to launch node itself and failing to find it. What's extra strange is that when Volta launches the node script, it sets the PATH to include Node, so it shouldn't be falling through back to Volta again.

Another possibility is that Volta failed to properly fetch Node the first time and left itself in a broken state where it thinks it's downloaded, but it doesn't actually have the appropriate file. Can you confirm what the contents of ~/.volta/tools/image/node/16.13.1/bin are?

hadasgazit commented 1 year ago

I got the same error. and BTW volta is running properly when running yarn install in the project. it is just those npx commands that results this error

hadasgazit commented 1 year ago

contant of ~/.volta/tools/image/node/16.13.1/bin is: drwxr-xr-x 2 hadasg hadasg 4096 Jan 30 08:47 . drwxr-xr-x 6 hadasg hadasg 4096 Jan 30 08:47 .. lrwxrwxrwx 1 hadasg hadasg 45 Jan 30 08:47 corepack -> ../lib/node_modules/corepack/dist/corepack.js -rwxr-xr-x 1 hadasg hadasg 79310832 Dec 1 2021 node lrwxrwxrwx 1 hadasg hadasg 38 Jan 30 08:47 npm -> ../lib/node_modules/npm/bin/npm-cli.js lrwxrwxrwx 1 hadasg hadasg 38 Jan 30 08:47 npx -> ../lib/node_modules/npm/bin/npx-cli.js

JonathanReiss15 commented 10 months ago

I encountered a similar error with an npx command. I was able to resolve the error by:

  1. deleting the target node version at ~/.volta/tools/image/node/
  2. Re-running command (reinstalled the target node version set by Volta)