Encountering maximum call stack size error during npm installation

I’m facing a maximum call stack size error every time I attempt to run the npm install command. The following is the output I see in the terminal:

npm ERR! Linux 4.8.0-27-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! Maximum call stack size exceeded
npm ERR! If you need assistance, consider reporting this issue at:
npm ERR!     <https://github.com/npm/npm/issues>

Additionally, here’s the content from the npm-debug.log:

113791 verbose stack RangeError: Maximum call stack size exceeded
113791 verbose stack     at Object.color (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/console-control-strings/index.js:115:32)
113791 verbose stack     at EventEmitter.log._format (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:252:51)
113791 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:138:24)
113791 verbose stack     at emitThree (events.js:116:13)
113791 verbose stack     at emit (events.js:194:7)
113791 verbose stack     at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18)
113792 verbose cwd /home/giorgi/AdMove/dev/web-advertiser-admove
113797 error Maximum call stack size exceeded

I have tried removing the node_modules directory multiple times and reinstalling, but I still cannot identify the cause of this issue or how to fix it. Any help would be appreciated.

This maximum call stack size error often stems from circular dependencies or an issue with your npm cache. Start by clearing your cache using npm cache clean --force. Then, review your package.json for any circular dependencies that could be causing the problem. A common solution is to delete the node_modules folder along with package-lock.json, followed by executing npm cache verify, and then trying the installation again. Additionally, since you’re running Node version 6.9.1, consider upgrading to a more recent LTS version, as older versions are frequently associated with such errors.

Check your global npm packages - they might be conflicting with your local install. I hit this exact same issue and it turned out a corrupted global package was causing recursive calls during dependency resolution. Run npm list -g --depth=0 to see what’s installed globally, then temporarily rename your global node_modules directory and try the install again. If it works, reinstall your global packages one at a time. Also check your .npmrc file for custom registry settings that could be messing with dependency resolution.