npm ERR! Maximum call stack size exceeded on Linux - npm-install

I use npm to install new component built by ReactJs. I can successfully install it on local windows machine. However, when I tried to use AWS codeBuild to build my client project, I encountered the following error in virtual machine:
npm ERR! Maximum call stack size exceeded
My npm version is 6.4.1.
When the build starts, the build process actually download npm and start to install packages based on package.json. So it is like to install packages on brand new machine.
I've tried to search online to see if there is anything similar and I couldn't find any solution.
Just plain 'npm install'

Related

npm install command doesn't work for me. ECONNRESET

I am trying to install an NPM package in a project but the installation does not go beyond the buildDeps phase and after a while it gives me the error ECONNRESET. This happens to me with any package I try to install:
I tried to install Express and Angular and couldn't.
Try connecting your device to Internet. NPM is a Package manager which add packages stored in servers and deliver to their users.
If problem still persists, try to install NodeJS again

Cannot find module 'postcss-preset-env' error using create-react-app inside an npm workspace

I'm trying to add a create-react-app app inside a Turborepo monorepo.
Problem is that if I run npm install from the root of the monorepo and then try to start the CRA app by running npm run dev, I get the following error during compile time:
Loading PostCSS "postcss-preset-env" plugin failed: Cannot find module 'postcss-preset-env'
I noticed that if I run npm install from within the CRA app folder (/apps/my-app), and then run npm run dev from the root of the monorepo, it runs just fine.
I also noted that depending from where I run npm install, the contents of /apps/my-app/node_modules will be different, but I think is the expected behaviour.
If I understand correctly the npm workspaces docs, you should always run npm install from the root of the monorepo.
Any idea on what I'm missing here?
I'm using npm 8.3.1.
Here is a public repo with an example: https://github.com/oncet/turborepo-cra

electron install error : Generated checksum for "electron-v2.0.2-win32-x64.zip" did not match expected checksum

I want to install latest electron version in my existing angular application.So I followed npm command to install it.
Command : npm i electron#latest
Expected Behavior
Electron should installed successfully.
Actual Behavior
So, Whenever I tried to install electron, after downloading zip file and SAMSUN.txt file , it is throwing below error....
Error: Generated checksum for "electron-v2.0.2-win32-x64.zip" did not match expected checksum.
at ChecksumMismatchError.ErrorWithFilename (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:41:124)
at new ChecksumMismatchError (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:56:133)
at Hash. (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:203:22)
at emitNone (events.js:106:13)
at Hash.emit (events.js:208:7)
at emitReadable_ (_stream_readable.js:513:10)
at emitReadable (_stream_readable.js:507:7)
at addChunk (_stream_readable.js:274:7)
at readableAddChunk (_stream_readable.js:250:11)
at Hash.Readable.push (_stream_readable.js:208:10)
Please note that I have tried to clear my npm cache using npm cache clean --force command and tried to install. but it didn't work.
I also tried to install electron globally using npm i -g electron#latest, but that approach also didn't work.
Please provide solution as soon as possible because I m really stuck at this problem.
Electron Version: 2.0.2
Operating System : windows
node version : 8.11.2
npm version : 6.1.0
Last known working Electron version:
We can solve this issue by using following steps (OS - Windows 10)
Delete "SHASUMS256.txt-x.x.xx" file from "C:\Users{{UserName}}.electron".
Delete Cache folder from "C:\Users{{UserName}}\AppData\Local\electron".
Delete electron from node_modules folder.
Then install electron globally and locally by using following commands -
npm init -y //Note: The -y flag provides default options automatically
npm install electron -g //install electron globally
npm install electron --save-dev --save-exact //install electron as devdependencies
If you are using typescript then install it as global using below command-
npm install -g typescript
Above steps may help you.

VS Code terminal fails to use npm version from nvm

I'm using nvm on my Terminal and successfully installed node 10.2.1, which also installed npm 6.1.0. However, when I go to my VS Code editor, it gives me warnings in the integrated terminal for:
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4,6, 7, 8, 9.
Turns out, it is actually using npm 5.5.1 (npm -v).
I check to see what's up with that and tried to dig further and eventually used: which npm on both integrated terminal and Mac's CLI.
Mac's Terminal shows:
/Users/Aiz/.nvm/versions/node/v10.2.1/bin/npm
VS Code's Terminal shows:
/usr/local/bin/npm. Which is interesting, because if you do which node in this terminal, it results in the appropriate /Users/Aiz/.nvm/versions/node/v10.2.1/bin/node.
I'm not sure how to get my VS Code terminal to point to the appropriate npm install through nvm. Not sure if it helps, but I checked npm get prefix and npm -g bin to find /Users/Aiz/.nvm/versions/node/v10.2.1. The only difference I'm finding is where each terminal is using npm from.
I ended up looking through VS Code issues on GitHub and came across something relevant to NVM and node issues. It fixed my issue since the underlying cause was the same.
Essentially what happened is that I had a global install of node before that I removed prior to using NVM but hadn't removed my global install of npm. This was causing conflicts in VS Code's terminal (not Mac's terminal). In order to fix this, you essentially have to find the symlink for which npm and remove the node_modules and npm associated recursively.
Here's the link you'll need: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched.
Don't forget to restart your editor after.
Another solution is to implement this. https://medium.com/#kinduff/automatic-version-switch-for-nvm-ff9e00ae67f3
Basically, nvm will check for a .nvmrc and switch or default each time you go to a new directory in shell.
It does have a dependency on zsh.
The fix for me on Ubuntu:
A.) sudo apt-get remove nodejs npm
B.) Removed lines in my .bashrc that added the npm package directory to the path.
C.) Restart VS Code.
I doubt step A is necessary. But B and C certainly are.

Correct way to use npm-cache VS Team Services

I'm currently using npm install to install all packages for an Angular2 project CI project, however this step has started to increase the time it takes build agents to build the project. I would like to get build run times down for our CI pipeline by using the npm-cache command, however I keep getting failed attempts at running the command through the build agent.
I have tried using a Command Line step with the following:
This result in the error File name doesn't indicate a full path to a executable file.
I have also tried added an npm step:
Which results in the following:
2017-06-14T13:01:13.2274922Z [command]C:\Program Files\nodejs\npm.cmd cache install
2017-06-14T13:01:19.8609829Z npm ERR! Usage: npm cache add tarball file
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add folder
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add tarball url
2017-06-14T13:01:19.8640981Z npm ERR! npm cache add git url
2017-06-14T13:01:19.8651863Z npm ERR! npm cache add name#version
2017-06-14T13:01:19.8661607Z npm ERR! npm cache ls path
2017-06-14T13:01:19.8672137Z npm ERR! npm cache clean pkg#version
What is the correct way to call npm cache from Team Services?
You need to install npm-cache package first, then call npm-cache command via command line task.
Add npm task (npm command: install; arguments: npm-cache -g)
Add Command Line task (Tool: C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm\\npm-cache; Arguments:install; Working folder: $(Build.SourcesDirectory))
Node: Previous steps uses the private build agent that running as service with NetworkService account. You can add C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm to system environment variable (restart machine is needed) and call npm-cache command directly.
You also can change build agent account to use your account (by default C:\Users\[user name]\AppData\Roaming\npm has added to user environment variable), then call npm-cache command after install npm-cache package with -g argument)
On the other hand, host agent won’t cache the packages, so it is useless if you are using hosted agent.