Error: The call stack has reached its maximum size while running an npm install

Attempting to execute npm install, encountered the following console output:

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! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

Additionally, here is the content of 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)
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)
113791 verbose stack     at emitThree (events.js:116:13)
113791 verbose stack     at emit (events.js:194:7)
113792 verbose cwd /home/giorgi/AdMove/dev/web-advertiser-admove
113793 error Linux 4.8.0-27-generic
113794 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
113795 error node v6.9.1
113796 error npm  v3.10.8
113797 error Maximum call stack size exceeded
113798 error If you need help, you may report this error at:
113798 error     <https://github.com/npm/npm/issues>
113799 verbose exit [ 1, true ]

Have already removed node_modules multiple times and attempted reinstallation. Unclear on the root cause of this issue and how to resolve it.

Answer №1

metzelder's solution really came through for me in solving the issue. However, if you execute the following command npm cache clean, you will receive a specific message.

Since npm@5, the npm cache can now heal itself from corruption problems and ensure that data taken from the cache is always accurate.

Therefore, with npm@5, you have the option to include the --force flag in the command.

The full command looks like:

npm cache clean --force

Answer №2

Running npm rebuild fixed the issue for me.

Answer №3

You can try deleting the package-lock.json file and the entire node_modules folder:

rm package-lock.json
rm -r node_modules

Answer №4

Dealing with a similar problem while running npm install, I came across a solution that worked for me. Removing the .npmrc file or its contents (located at %USERPROFILE%/.npmrc) resolved the issue after some investigation. Hopefully, this tip helps anyone facing a similar challenge.

Answer №5

Running into an issue with my npm packages, I attempted to fix it by executing the following commands:
npm uninstall
npm cache clean --force

Unfortunately, these methods did not resolve the issue. As a last resort, I decided to remove the node_modules directory and reinstalled the packages using npm install. However, even this step failed to solve the problem. Eventually, I deleted the package-lock.json file and generated a new one by running:

npm install

Answer №6

To resolve this issue, I followed these steps:

  • I cleared out all the content of the npm dependencies folder. For information on where to find the default install location, refer to this thread:

  • Before executing the npm install command, it is advisable to first run npm cache clean --force

Answer №7

Personally, I always make sure to stay up-to-date by installing the latest version:

npm update -g npm

Answer №8

Using the command npm rebuild is guaranteed to fix the issue.

Answer №9

I removed the 'node_modules' folder from my project directory

node_modules

and then I reinstalled all the dependencies using the command 'npm install'

npm install

This solution successfully resolved the issue for me

Answer №10

I encountered a similar issue and found a solution that worked for me.

  1. Start by ensuring your node and npm versions are current. If not, update to the latest versions using the following commands:

    nvm install 12.18.3 // use node version manager to update
    
    npm install npm // update npm version
    
  2. Delete the node_modules folder and package-lock.json file.

  3. Perform a force clean of the entire NPM cache with this command:

    npm cache clean --force
    
  4. Re-install all dependencies with:

    npm install
    
  5. If the issue persists, try re-installing dependencies after running the following command:

    npm rebuild
    

Answer №11

Encountering this problem is not uncommon when attempting to install a non-existent package or an unavailable version.

Answer №12

When you use npm cache clean, a message is returned indicating that the cache has been cleared.

Starting from npm@5, the npm cache can automatically fix any corruption issues, ensuring that the data extracted from the cache is always valid. To verify consistency, it is recommended to use 'npm cache verify' instead. However, if you are troubleshooting an installer problem, you can use

npm install --cache /tmp/empty-cache
to temporarily switch to a different cache without deleting the existing one.

By running npm cache verify, as mentioned above, you initiate cache verification and garbage collection processes that address potential issues within the cache.

The cache has been verified and compressed (~\AppData\Roaming\npm-cache_cacache): Content verified: 6183 (447214684 bytes) Content garbage-collected: 16 (653745 bytes) Index entries: 9633

Answer №13

Summary

If you're using NVM, ensure that you have the correct versions of Node and NPM installed.

Context

I encountered an error after switching to NVM for a new project. When attempting to run npm install on my work project, I received an error indicating that the maximum call stack size had been exceeded.

The issue was traced back to me using Node 12 and its respective NPM version when I should have been using Node 16.

Resolution

To fix this problem, switch to a more recent version of Node and NPM;
nvm use <version> (e.g., nvm use 16)

Answer №14

Encountered this issue while working with docker (node:15-buster).

Make sure to specify the WORKDIR /<folder> to avoid any conflicts with existing npm libraries.

Choose any folder name except system directories, for example avoid using /.

Answer №15

If none of the provided solutions work for you, it may be due to using the wrong terminal or if your node_modules directory is being accessed by another part of your computer.

In my experience, I encountered repeated errors like "maximum call stack size exceeded" and permission issues even after running sudo npm i.

The solution that worked for me was closing my IDE (I was using WebStorm), running npm i in a basic terminal, and that resolved the issue.

Answer №16

During my experience, I encountered an issue with a personalized .npmrc configuration file containing an authentication token for accessing a private npm repository.

The token had expired, leading to a helpful

error E401: Password incorrect or missing
message when testing locally, but resulting in an
ERR! Maximum call stack size exceeded
error during the CI build.

Answer №17

As someone who doesn't use Windows, I suggest Windows users refer to Rene Knop's comment.

For those using Unix/OSX, I deleted the root .npmrc file ~/.npmrc. Before attempting this, make sure there is no important information in that file. You can view all contents in your terminal with this command: cat ~/.npmrc.

If you receive an error message like:

cat: /Users/$USER/.npmrc: No such file or directory

to make a backup:

cp ~/.npmrc ~/.npmrc_copy

Now, delete it (for bash users on Unix / Ubuntu / OSX...):

rm -f ~/.npmrc

This method worked for me. Hopefully, it proves helpful to others as well.

Answer №19

Typically, after installing a module, it's more efficient to utilize npm ci rather than npm install. To understand the benefits of the former over the latter in a production setting, please refer to this information on Stack Overflow. To resolve any issues, simply execute

npm ci

This action will update all dependencies and address the problem. However, if there is significant disparity between the two, an error may occur.

Answer №20

To completely remove an npm package, you can first uninstall it and then clean the cache by following these steps:

$sudo npm uninstall <package-name>
$sudo npm cache clean --force

After completing the above steps, make sure to restart your terminal and check if the issue has been resolved.

If the problem persists, consider upgrading both npm and node to their latest versions.

Answer №21

Today we experienced a problem while executing an npm prune command even though we had already tried using npm cache clean --force.

Software versions:

node 13.8.0 
npm 6.13.6

In this situation, deleting the package-lock.json file also resolved the issue. Many thanks to everyone for their help!

Answer №22

Many instances of this problem arise when utilizing the system designated by your employer, which may have restrictions on certain commands through its VPN. If facing this issue, consider disconnecting from the organization's VPN before attempting to run the command.

Answer №23

I was faced with an issue on my Mac that seemed impossible to fix. It all began when I downloaded npm from Node.js and later decided to reinstall it using Homebrew while following a tutorial on Team Treehouse.

My Attempts at Fixing the Issue:

I first tried the steps outlined in this article:

sudo npm uninstall npm -g
sudo make uninstall
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

Next, I followed the instructions provided in this Stack Overflow post:

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

What Finally Resolved the Issue:

After exhausting all other options, I resorted to cloning the npm-reinstall repository from GitHub. This comprehensive tool completely wiped out any traces of npm on my Mac.

You can find the npm-reinstall repo here: https://github.com/brock/node-reinstall

Once that was done, I had to reinstall both node and npm directly from Node.js.

Answer №24

After tirelessly attempting various solutions to resolve the issue on my Windows 7 computer,

including multiple attempts at reinstalling and rebuilding npm,

I ultimately discovered that a minor configuration setting was causing the problem, resulting in me spending an entire day troubleshooting.

The Solution to My Problem

Ultimately, I found success by removing the project-specific configurations from my global .npmrc file located at drive:/Windows/Users/../.npmrc

Answer №25

After some troubleshooting, I was able to successfully resolve the issue. The problem originated from using gulp version 3.5.6.

The solution involved clearing the package-lock.js file and subsequently running npm install, which effectively resolved the issue.

Answer №26

Within our organization's development environment, we rely on Artifactory as the primary repository for all of our NPM packages. However, I encountered an issue where running npm install defaulted to Artifactory instead of the desired registry, causing problems. To resolve this, I manually specified the main npm registry using

npm install --registry https://registry.npmjs.org
, which successfully resolved the issue for me.

Answer №27

Dealing with a similar issue, I attempted to integrate jest into one of the components within a monorepo setup.

For those utilizing Yarn + Learna for managing a monorepo structure, it is necessary to access the package.json file in the specific component and execute either npm install or npm install <package name>.

Answer №28

Give this a shot first!

Re-run the npm install command

This may seem overly simple, but I decided to share it here in case it helps someone who hasn't tried it yet. I recommend trying this approach initially since it is straightforward and doesn't carry the potential risks mentioned in other solutions, such as deleting package-lock.json.

Theory:

This hypothesis is purely speculative, as I am currently working on a code project that is completely new to me. My assumption was that some packages may not have been fully installed during the initial run of npm install, likely due to resource limitations.

I hypothesized that by running npm install again, it would skip over previously installed packages and either complete successfully or make more progress. The observed behavior aligned with my theory, although I did not thoroughly test or debug to confirm if my hypothesis was accurate.

It's evident that various solutions have proven effective for different individuals, but I felt compelled to contribute an answer to this frequently asked question based on its simplicity.

If you're fortunate, perhaps the installation process will provide enough time for you to enjoy a relaxing cup of 🍵 or ☕ 😉

Answer №29

Encountering a similar issue, I discovered that the culprit was a recent update to my git executable. Reverting back to Git-2.21.0.rc1.windows.1-64-bit and including it in my environment path resolved the problem entirely.

Answer №30

After struggling with Mac compatibility, I finally found success by upgrading from node 8.12 to version 10.x using NVM.

I decided to uninstall all previous Node versions through NVM, then proceeded to install the 10.x version. Finally, I ran the command nvm alias default node, which instructs NVM to always default to the latest available node version in a shell.

Following these steps, my live reloading issue miraculously disappeared! Success at last!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The language is being detected, but the translation feature is not functioning properly with i18n

I've configured the i18n middleware in my Express Node js server as follows: // server.js import i18nMiddleware from 'i18next-express-middleware'; import i18n from 'i18next'; import Backend from 'i18next-node-fs-backend'; ...

What is the best way to activate a CSS animation?

I've hit a roadblock while attempting to trigger a CSS animation. Here's my CSS: h3[id="balance-desktop"]{ color: black; -webkit-animation-name: gogreen; -webkit-animation-duration: 2s; animation-name: gogreen; animation-du ...

Selecting radio buttons across multiple div classes

I've been struggling to programmatically select specific radio buttons on a webpage. My goal is to automatically choose the second option in each group of radio buttons, but I'm getting lost in the syntax. Unlike most examples I've found on ...

An error occurs when attempting to assign a value to a MUI file TextField

Struggling with setting the value of a MUI Textfield that has type="file" props, resulting in the following exception being thrown: Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable Interest ...

What steps should I take to fix the issue of "[ERR_REQUIRE_ESM]: Must use import to load ES Module" while working with D3.js version 7.0.0 and Next.js version 11.0.1?

Encountered a roadblock while integrating D3 with Next.js - facing an error when using D3.js v7.0.0 with Next.js v11.0.1: [ERR_REQUIRE_ESM]: Must use import to load ES Module Tried utilizing next-transpile-modules without success Managed to make D3.js ...

Adding a character to an AngularJS textbox

I am attempting to add the "|" Pipe symbol to a textbox when a button is clicked, using this function. $scope.appendPipe = function(){ var $textBox = $( '#synonyms' ); $textBox.val($textBox.val()+'|'); //textBox ...

Error: Chrome is preventing an AJAX request

Hello everyone, I have been facing an interesting issue with my Ajax request. It seems to work perfectly fine in Internet Explorer, which is quite surprising. However, when I attempt to run the same code in Chrome, I encounter the following error: XMLHt ...

I encountered difficulty executing a nodejs child_process on my Amazon EC2 instance

I'm utilizing the nodejs child_process function spawn() to execute a mongoexport. I have provided all the necessary parameters to the command and it's functioning correctly on my local setup. Below is the code snippet for the function: userDetai ...

Modifying the header of a NodeJS response with the request package

I have encountered an issue that I need assistance with: My goal is to retrieve a static file from a different server and return it to the user with an altered content-type header. The code below successfully achieves this, but I am struggling to find a ...

Changing a background image url using jQuery by clicking a button

I'm struggling to find a way to use jQuery to add a background image URL to my CSS. Everything I've attempted so far has been unsuccessful. let button = document.querySelector('form button.btn') button.addEventListener('click&ap ...

Creating a custom regular expression in ExpressJS: matching a parameter to all routes except for one

My current route is set up to catch the code param in the following way: app.get('/:code([a-zA-Z]{3})', codeHandler); This setup successfully matches all three-letter codes, but now I want to modify it to exclude one specific code. For example, ...

Tips for navigating a dynamic viewport using scroll movement

Attempting to create a responsive page with two distinct sections at this example link including: Map View Table View Both of these views (table and map divs) need to be responsive without a hard-coded height, so the size of the map div adjusts automatic ...

Setting up NestJs with TypeORM by utilizing environment files

In my setup, I have two different .env files named dev.env and staging.env. My database ORM is typeorm. I am seeking guidance on how to configure typeorm to read the appropriate config file whenever I launch the application. Currently, I am encountering ...

Customizing build dependencies in Google App Engine allows developers to tailor their applications to

For my application to be built, it requires cmake, libx11-dev, and libpng-dev. I found guidance in this documentation suggesting that these dependencies can be listed for the Google App Engine platform, but I am unsure of the process. While I managed to ...

Deleting a row from a table in AngularJS can be accomplished by following these steps

I am having trouble with deleting rows from a table using angularjs. When I try to delete a row, it ends up deleting the previous row instead of the correct one. How can I fix this issue? Please check out the working DEMO Here is the code snippet: < ...

react-native-track-player failing to play song requested from Express server

I set up an expressjs server with a 'songs' route that serves .mp3 files. Here is the code for the Songs Route: import express from "express" const path = require("path") const router = express.Router() ... router.get(" ...

Ensure that the line above is shorter in length compared to the following line

Is there a way to ensure that the previous line of text is always shorter than the next one, even if the length of the text is unknown? For example: Lorem ipsum dolor sit amet, consectetur adipiscing et libero posuere pellentesque. Vivamus quis nulla jus ...

Guide to ordering objects within an array by their createdAt property in mongoose

I'm attempting to organize the products array based on the createdAt date. Here is my orders model: const itemSchema = new Schema( { productId: { type: Schema.Types.ObjectId, ref: 'Product' }, quantity: { typ ...

Unique alphanumeric code following the inclusion of a JavaScript file

I'm encountering an issue with a webpage that incorporates two JavaScript files. When inspecting it using firebug, I noticed that every time the page loads, these two files are included with the prefix ?_=someRandomNumber I'm unsure about the or ...

When incorporating axios within an express route, it is causing the data field to display unusual characters instead of JSON

I've been grappling with this issue for quite some time now, and any assistance would be greatly appreciated. Initially, I attempted to resolve the problem by utilizing the Moralis nodeJs library. While it worked fine on my local environment, it retu ...