# Netlify CLI fails to install

**URL:** <https://answers.netlify.com/t/netlify-cli-fails-to-install/34508>\
**Category:** Support\
**Tags:** netlify-cli\
**Created:** [March 18, 2021, 3:29pm UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508 "2021-03-18T15:29:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesignedByNino](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/designedbynino/32/23461_2.png) [@DesignedByNino](https://answers.netlify.com/u/DesignedByNino)\
**Post date:** [March 18, 2021, 3:29pm UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/1 "2021-03-18T15:29:02Z")

</div>

I am trying to install the Netlify CLI via `sudo npm install netlify-cli -g` on my mac running MacOS Big Sur 11.2.3 and it throws this npm error :

```auto
sudo npm install netlify-cli -g  127 ✘
Password:

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.

> yarn@1.22.10 preinstall /usr/local/lib/node_modules/netlify-cli/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

/usr/local/bin/netlify -> /usr/local/lib/node_modules/netlify-cli/bin/run
/usr/local/bin/ntl -> /usr/local/lib/node_modules/netlify-cli/bin/run

> esbuild@0.8.57 postinstall /usr/local/lib/node_modules/netlify-cli/node_modules/esbuild
> node install.js

Trying to install "esbuild-darwin-64" using npm
Failed to install "esbuild-darwin-64" using npm: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/esbuild-lcsaklv44g'
Trying to download "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.8.57.tgz"
/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/install.js:178
      throw e;
      ^

Error: EACCES: permission denied, open '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/bin/esbuild'
    at Object.openSync (fs.js:476:3)
    at Object.writeFileSync (fs.js:1467:35)
    at installBinaryFromPackage (/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/install.js:42:6)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/bin/esbuild'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-win32-x64@^0.27.10 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent/node_modules/@netlify/traffic-mesh-agent-win32-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-win32-x64@0.27.10: wanted {"os":"win32","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-linux-x64@^0.27.10 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent/node_modules/@netlify/traffic-mesh-agent-linux-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-linux-x64@0.27.10: wanted {"os":"linux","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
npm WARN @octokit/plugin-request-log@1.0.3 requires a peer of @octokit/core@>=3 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! esbuild@0.8.57 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the esbuild@0.8.57 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nino-p/.npm/_logs/2021-03-18T15_03_23_690Z-debug.log

```

---

<div class="post-metadata">

**Author:** ![DesignedByNino](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/designedbynino/32/23461_2.png) [@DesignedByNino](https://answers.netlify.com/u/DesignedByNino)\
**Post date:** [March 18, 2021, 3:51pm UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/2 "2021-03-18T15:51:58Z")

</div>

I tried installing it without the `sudo` comand and it failed, I tried one more time without `sudo` and it actually installed successfully. Weird stuff, but it worked 😉

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [March 18, 2021, 3:54pm UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/3 "2021-03-18T15:54:33Z")

</div>

Hey there, @DesignedByNino

Thank you so much for sharing your solution, I appreciate it! This is always beneficial for future Forums members who may encounter something similar.

---

<div class="post-metadata">

**Author:** ![azarai](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/azarai/32/17643_2.png) [@azarai](https://answers.netlify.com/u/azarai)\
**Post date:** [April 14, 2021, 9:58am UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/4 "2021-04-14T09:58:54Z")

</div>

Did not work for me. Even tried older netlify-cli and removing `~/.npm`.

What did work for me:

- Solution A: `sudo npm install netlify-cli -g --unsafe-perm`
- Solution B: `sudo chmod o+w /opt/local/lib/node_modules`and then install without sudo. But everything belongs to the current user now.

Strange thing as I did not change anything on my system.

---

<div class="post-metadata">

**Author:** ![kylesloper](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kylesloper/32/18398_2.png) [@kylesloper](https://answers.netlify.com/u/kylesloper)\
**Post date:** [April 14, 2021, 10:03am UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/5 "2021-04-14T10:03:37Z")

</div>

Thanks for sharing this! People like you make Netlify Forums great 😀 :netliheart:

---

<div class="post-metadata">

**Author:** ![mshekh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/mshekh/32/26956_2.png) [@mshekh](https://answers.netlify.com/u/mshekh)\
**Post date:** [June 29, 2021, 5:42am UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/6 "2021-06-29T05:42:15Z")

</div>

Thanks for sharing here, i just applied your solution B and it worked for me.

but small change in path:

in your case: sudo chmod o+w /opt/local/lib/node\_modules  
in my case: sudo chmod o+w /usr/lib/node\_modules

😀 👍

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [June 29, 2021, 8:15am UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/7 "2021-06-29T08:15:43Z")

</div>

Hi, @mshekh. I must point out that installing `netlify-cli` using `sudo` is neither required nor recommended.

---

<div class="post-metadata">

**Author:** ![jamaalhassan](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jamaalhassan/32/30379_2.png) [@jamaalhassan](https://answers.netlify.com/u/jamaalhassan)\
**Post date:** [October 14, 2021, 5:42pm UTC](https://answers.netlify.com/t/netlify-cli-fails-to-install/34508/8 "2021-10-14T17:42:03Z")

</div>

Solution A worked for me everyone is different
