antfu-collective / ni

💡 Use the right package manager
MIT License
6.54k stars 214 forks source link

ni doesn't seem to run with the correct node/pnpm version #96

Closed mcmxcdev closed 2 years ago

mcmxcdev commented 2 years ago

Describe the bug

I just installed ni the first time with pnpm i -g @antfu/ni then executed ni inside a project.

Unfortunately, I ran into an error due to our strict-engine setting:

ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your pnpm version is incompatible with "/home/<user>/Applications/Webdevelopment/Freelancing/<repo>/<project>".

Expected version: ^7.8.0
Got: 6.32.9

This is happening because the package's manifest has an engines.pnpm field specified.
To fix this issue, install the required pnpm version globally.

To install the latest version of pnpm, run "pnpm i -g pnpm".
To check your pnpm version, run "pnpm -v".

Your Node version is incompatible with "/home/<user>/Applications/Webdevelopment/Freelancing/<repo>/<project>".

Expected version: ^16.15.0
Got: v16.14.2

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.

But when I check for node/pnpm version, I get this output:

$ node -v
v16.16.0
$ pnpm -v
7.8.0

ni seems to pick up an old node version that I have installed with volta, see:

$ volta list node

⚡️ Node runtimes in your toolchain:

    v16.14.2
    v16.15.0 (default)
    v16.16.0 (current @ /home/<user>/Applications/Webdevelopment/Freelancing/<repo>/<project>/
    package.json)

Where it gets pnpm v6.32.9 from, I have no clue.

Reproduction

-

System Info

System:
    OS: Linux 5.18 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
    Memory: 11.56 GB / 15.61 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.volta/tools/image/node/16.16.0/bin/node
    Yarn: 1.22.19 - ~/Applications/Webdevelopment/Freelancing/myZorro/myZorro/node_modules/.bin/yarn
    npm: 8.11.0 - ~/.volta/tools/image/node/16.16.0/bin/npm
  Browsers:
    Brave Browser: 104.1.42.86
    Firefox: 103.0

Used Package Manager

pnpm

Validations

antfu commented 2 years ago

I don't know about Volta, PR welcome if you find a fix for it

mcmxcdev commented 2 years ago

I was actually able to fix this by removing volta completely and reinstalling right now. No idea why it happened though.

Now at least people can find this thread when they search for similar issues.