Search code examples
laravelnpmphpstorm

Ubuntu terminal and PhpStorm terminal shows different node versions


Trying to npm install in my project but I'm getting error like

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@vitejs/[email protected]',
npm WARN EBADENGINE   required: { node: '^14.18.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=14' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=14.18.0', npm: '>=8.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '^14.18.0 || >=16.0.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }

When I try to check my node version in my Ubuntu terminal, it says v18.x.x. But in PhpStorm's terminal it say v12.x.x. So I am getting an error while I'm trying to run my project. Can you help me?

Trying to update node with npm but not worked.

EDIT: Tried uncheck Add 'node_modules/.bin' from the project root to $PATH section in phpStorm settings but not worked.


Solution

  • I had this issue and it was due to the Add default project PHP interpreter to $PATH option being checked in the terminal settings (CTRL S -> Tools -> Terminal).

    If you aren't maintaining separate php versions in separate directories for each project, you should uncheck this option.

    EXPLANATION:

    What it does is prepend /bin or /usr/bin (depending on where your selected php interpreter is installed) to your $PATH. This causes any other binaries that you have installed in /bin or /usr/bin to override the version you may expect to see. You probably have node version 12.x.x installed in /bin and 18.x.x is installed in /usr/local/bin