Error adding netlify-cli with yarn

Hi there! I have been using the command ‘yarn add netlify-cli -g’ in my react projects and deploying them to netlify without any problem. But i don’t know what happened and since today i have been facing some troubles when i want to do this. I use that command as usual but i get this error:

My nodejs version is 16.13.1. I dont know what to do or how to solve this and it’s very frustrating because i’m not being able to deploy my projects :frowning: any help?

Hi @lklk03

I see warnings, but I don’t see any errors in the screenshot provided.

In the command yarn add netlify-cli -g the -g flag denotes a global install. This means you do not need to add netlify-cli to each individual project. If it is installed globally, the netlify command is available everywhere.

I don’t use yarn myself, but yarn add doesn’t even seem to have a -g flag when looking at the options here:

I believe it’s supposed to be yarn global add:

However it also doesn’t seem to be the problem that’s being experienced.

What’s happening on my system is that it repeatedly hangs on the line:

warning "netlify-cli > @netlify/build > ts-node@10.4.0" has unmet peer dependency "typescript@>=2.7".

Eventually causing a JavaScript heap out of memory error.

I’ve yet to pinpoint what’s occuring, but I’ve tried multiple versions of node, multiple versions of yarn and multiple versions of the netlify-cli, with all failing.

Have you tried installing the netlify-cli globally just using npm instead of yarn:

npm i -g netlify-cli

I’ve just noticed that yarn global is actually yarn classic… shows how out of touch I am with it.

Or not… since we’re talking about v1.22.17 which is apparently Classic, so it’s really my first link that’s wrong as thats for v2.

There doesn’t seem to be a -g flag for add in the Classic version either and they explicitly draw attention to yarn global:

Indeed, an oversight on my part; global is the yarn (classic) way.

Using yarn add netlify-cli (yarn add v1.22.17) to add to a project failed for me also (node.js v16.13.1).

Using npm add netlify-cli did work though.

All my tests have shown the same thing.

I can’t get yarn to install the netlify-cli regardless of the node / yarn / netlify-cli versions I’ve tried.

It installs fine with npm via npm i -g netlify-cli.

@nathanmartin @coelmay hey, thanks for your answers. I’ll try what you suggested about using npm and then I’ll comment again. Hope I can get success this time :smile:

Have opened an issue on the netlify-cli repository

1 Like

I’ve added comments to the issue filed here:

https://github.com/netlify/cli/issues/3788

The issue is not in the Netlify CLI. The issue is in yarn or one of its dependencies.

The only workaround that I have been able to find it to switch to npm instead of yarn. There are more details on the issue @coelmay created.

2 Likes

Hi all :wave:

We have identified the issue causing this and provided several workarounds in the issue, both for global installations and for local ones.

We’re still working on fixing the underlying issue and we’ll publish a fixed version of the CLI next week.

1 Like

So finally i found the solution in this thread yarn add netlify-cli fails with "JavaScript heap out of memory" · Issue #3788 · netlify/cli · GitHub, adding the following code to my package.json

“resolutions”: {
@oclif/plugin-help”: “3.2.14”
},

Thanks for all who helped me with this trouble, you’re really such a great community! :smiley:

1 Like

Thanks so much for coming back and sharing this solution, @lklk03! :netliconfetti: This will definitely help future members who are encountering something similar.

Hello again :wave:

oclif released a fix for this so the resolutions workaround is no longer required, see yarn add netlify-cli fails with "JavaScript heap out of memory" · Issue #3788 · netlify/cli · GitHub

2 Likes