Search code examples
npmyarnpkg

Npm said I don't have yarn, but I already installed with Npm


I am doing my nestjs project. I recently setup my new macbook pro.

I have Node, Npm, and Yarn installed. But when I tried to install class-validator and class-transformer package with Npm, I got a error message :

Unsupported engine. required: { node: '>= 10.13.0', npm: '^6.11.0', yarn: '>= 1.13.0' }, current: { node: 'v15.11.0', npm: '7.6.0' }

But when I type npm -g ls, or yarn --version, yarn is there. How should I fix it?

Thanks.


Solution

  • The node version seems to be fine because we have in the above case 15.11.0 and the requirement is >= 10.13.0, which means that any version higher than 10.13.0 is fine. (Including higher major versions as well.)

    The required npm version is ^6.11.0 and the current version is 7.6.0. The ^ character in the requirement means, that the major version should be identical and the minor and patch version can change to a higher version. (Versioning terms are documented here.)

    This means, that the installed npm version should have major version 6, in the above case we have 7. It follows that an npm version should be used that has 6 as major version.