Upgrading npm fails with too many symbolic links encountered, access '/usr/lib/node_modules/npm/node_modules/openzeppelin-solidity'

I tried to run sudo npm install -g npm to upgrade from 6.9.0 → 6.12.0.
(I have to always use sudo whenever installing anything with npm for some reason.)
I got this error:

joe@joeslinux:/usr/lib/node_modules/npm/node_modules$ sudo npm install -g npmnpm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/openzeppelin-solidity
npm ERR! path /usr/lib/node_modules/npm/node_modules/openzeppelin-solidity
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall access
npm ERR! ELOOP: too many symbolic links encountered, access '/usr/lib/node_modules/npm/node_modules/openzeppelin-solidity'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/joe/.npm/_logs/2019-10-12T14_02_25_800Z-debug.log

when I tried to navigate to that directory, I got the same error:
:~$ cd /usr/lib/node_modules/npm/node_modules/openzeppelin-solidity bash: cd: /usr/lib/node_modules/npm/node_modules/openzeppelin-solidity: Too many levels of symbolic links

Then I noticed this line from ls run from /usr/lib/node_modules/npm/node_modules
lrwxrwxrwx 1 root root 21 Jul 13 13:33 openzeppelin-solidity -> openzeppelin-solidity

When I originally installed open zeppelin many months ago, I went by the instructions as they were presented. I never had any issues with npm until today. I’m only getting around to experimenting with open zeppelin, so I can’t say whether it works or not.

1 Like

Hi @Joe,

You shouldn’t need to use sudo with npm. If you are not already you may want to look at using nvm.

See npm documentation for details on the recommendation to use a node version manager:

It also sounds like you may have openzeppelin-solidity installed globally, when you only need it installed locally for a specific project. Also the current name is @openzeppelin/contracts.

Once you have resolved the issue with npm, you can follow the instructions in the [Getting Started] guide:

Hi @Joe,

Were you able to resolve or are you still having issues?

I deleted the project’s directory and started over. Then, I also
deleted that self-referencing symbolic link, that being in a
different version of npm, in my ~ directory. That cleaned up the

1 Like

Hi @Joe,

Glad you were able to resolve.