Home > Back-end >  Maximum call stack size exceeded; removing node_modules and package-lock.json and running 'npm
Maximum call stack size exceeded; removing node_modules and package-lock.json and running 'npm

Time:04-13

Not meaning to add another 'maximum call stack size exceeded' question, but I've tried probably every other suggestion on stackoverflow (I think).

Versions:

node v.14.19.0
npm v.6.14.16

Below is the log with the error.

> [email protected] postinstall C:\\folder\\node_modules\@angular-devkit\build-angular\node_modules\esbuild
> node install.js


> [email protected] postinstall C:\\folder\\node_modules\ng-packagr\node_modules\esbuild
> node install.js


> [email protected] postinstall C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx
> node ./bin/init

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'tar-stream'
Require stack:
- C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\src\utils\fileutils.js
- C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\src\utils\cache-directory.js
- C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\src\project-graph\nx-deps-cache.js
- C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\src\project-graph\project-graph.js
- C:\\folder\\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\bin\init.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (C:\folder\node_modules\nx\node_modules\@nrwl\tao\node_modules\nx\src\utils\fileutils.js:11:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\folder\\node_modules\\nx\\node_modules\\@nrwl\\tao\\node_modules\\nx\\src\\utils\\fileutils.js',
    'C:\\folder\\node_modules\\nx\\node_modules\\@nrwl\\tao\\node_modules\\nx\\src\\utils\\cache-directory.js',
    'C:\\folder\\node_modules\\nx\\node_modules\\@nrwl\\tao\\node_modules\\nx\\src\\project-graph\\nx-deps-cache.js',
    'C:\\folder\\node_modules\\nx\\node_modules\\@nrwl\\tao\\node_modules\\nx\\src\\project-graph\\project-graph.js',
    'C:\\folder\\node_modules\\nx\\node_modules\\@nrwl\\tao\\node_modules\\nx\\bin\\init.js'
  ]
}
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\xyz\AppData\Roaming\npm-cache\_logs\2022-04-08T20_00_17_654Z-debug.log

I have tried

  1. removing the node_modules folder and package-lock.json and running npm i.
  2. removing the npm cache in AppData, doing #1, and then running npm i.
  3. running npm cache clean, doing #1 and then running npm i. (probably the same thing as #2 tbh.)
  4. installing a different version of node (14.17.0-> 14.19.0) and running npm i.
  5. globally installing the missing module (tar-stream) and running npm i
  6. checking environment variables- I have a path var = C:\Program Files\nodejs
  7. checking permissions

Any suggestions? Please let me know if there's any additional info needed.

CodePudding user response:

I had this problem myself, its a new issue related to the nested dependencies in @nrwl/cli.
Add this to your package.json:

"optionalDependencies": {
   "@nrwl/cli": "13.7.1"
}

Source: https://github.com/nrwl/nx/issues/9755

  • Related