installing a module in the global location, when a previous version exists, results in a symbolic link LOOP

While working on a macOS Mojave v10.14.4, and using nodejs/npm installed via homebrew I get a repeatable and quite weird error/bug. I am using node v10.12.0 and npm v6.9.0.

If I have a module, say semver, already installed in my global node_modules directory (/usr/local/lib/node_modules) and I try to install a new version of semver globally via npm i -g semver, then I get the following error:

$ npm i -g semver
npm ERR! path /usr/local/lib/node_modules/semver/bin/semver
npm ERR! code ELOOP
npm ERR! errno -62
npm ERR! syscall chmod
npm ERR! ELOOP: too many symbolic links encountered, chmod '/usr/local/lib/node_modules/semver/bin/semver'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myusername/.npm/_logs/2019-05-22T09_23_59_243Z-debug.log

Before I had a valid install of semver in /usr/local/lib/node_modeules/semver/ with a package.json and all the correct files. Now I have a self referencing symbolic link loop.

$ ls -l semver
lrwxr-xr-x  1 myusername  staff  6 May 22 05:23 semver -> semver

I think this is a genuine bug.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.