How to see logs from npm installation? - npm-install

I am unable to install ionic through npm. Are there any logs that I can check to see what's wrong and if yes, where are they located?
What I see is the waiting stick dancing forever. I've waited for an hour or so but nothing changes.

Append the --loglevel verbose argument to the command you want to run and all logs will be shown on STDERR and saved to npm-debug.log file in the current working directory.
Example usage: npm install ionic --loglevel verbose.
Running the npm commands like this, shows the logs in realtime and saves the logs to the directory its running within.
For permanent solution, just edit the global npm configuration. To do this, run npm config edit command and add loglevel=verbose. Now every npm command will show detailed logs

Related

NPM stuck on idealTree: timing idealTree

Today i decided to start react native cli project. Everything works great since i want to add new lib of course using npm . So i ran npm install ... . And this command always stuck on
Image
idealTree: timing idealTree Completed in 3440ms
And nothing happened. So i tried to ran
npm install --verbose
And again stuck on the same place. Also clear cache npm cache clear --force and nothing happened again. I don'n know how to fix this
I have had npm install freeze on me numerous times, lately. I'm not sure of the cause. When that happens I follow these steps:
Kill the npm install process with ctrl+c.
Delete node_modules. If there are files that you cannot delete because they are currently in use, that may mean that the npm install process was not successfully stopped. Try opening Task Manager and ending all nodejs and terminal processes. If this fails, restart your pc and then delete node_modules
Clean cache and reinstall node_modules with npm cache clean --force && npm i
This has happened to me a few times before and all I had to do was kill my dev server before running npm install.
Hope that helps as well!
I had the same issue on node latest version v18.8.0 and npm v8.18.0, I just downgraded to node 16.6 using nvm and it worked fine.
For me, the issue was that I had node running for a separate project. Terminating the other node process fixed the issue.
When i opened my package.json i saw '~2.2.1' in front of react-native-gesture-handler which probably means that it was notinstalled properly
Just close all terminals and then open task manager and kill all the processes corresponding to NodeJS. Then install it again.
Hopefully it will resolve.
I also faced this problem and the solution was simple by stopping all the "nodejs terminals" that are working outside.
When you stop nodeJS Terminals running in the background, it will complete the current installation process.
enter image description here
When you want to add package on your project it is better to stop server before adding new package.
I had same problem but after doing this it is solved.

npm or yarn test fails with "npm ERR! enoent spawn bash ENOENT"

I am trying to follow a tutorial on how to fork Compound (https://medium.com/compound-finance/a-walkthrough-of-contributing-to-the-compound-protocol-9450cbe2133a). I want to add a new token. But in order to do that, I need to first be able to get the app to pass all tests.
The problem is that I can't get the tests to run in the first place. According to the tutorial, I simply need to type yarn test to run the tests. However, when I try to do this, I get error messages that seem to imply that it cannot find the path to the test file. For example:
'.\script\test' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command." >
or
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\tombl\Documents\Code\compound-protocol
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent>
After investigating some, I discovered that it is trying to run a script in package.json called "test".
The script looks like this: "test": "./script/test",
At first, I got a response saying that "." is not a recognized command. I then tried to put the entire pathname in it so that it wouldn't have a period in it. So I edited package.json to say "test": "C:/Users/tombl/Documents/Code/compound-protocol/script/test",
That didn't work. Next, I tried to edit the environment variables in Windows so that CMD would recognize the folder (I'm using a terminal from within Visual Studio Code). That didn't work either.
After reading some other stack exchange answers, I followed the advice here (npm - The system cannot find the path specified) and typed npm config set script-shell bash. This also didn't work.
In addition, I tried editing package.json so that there is a second set of quotes in the path, like this: "test": "'C:/Users/tombl/Documents/Code/compound-protocol/script/test'", But it still didn't work.
Oh, and I tried using npm test instead of yarn test.
At this point, I have no idea what to try next.
I can see very clearly in file manager that the "test" file is there and that the path I've stated is correct. I can even open up the test file and see the code inside of it. But I can't get the terminal to run it. It just says that it isn't there.
One clue I do have is that it stops at the folder "compound-protocol". So it either doesn't recognize the folder compound-protocol at all or it doesn't recognize that the script folder is inside of it.
I've wondered if maybe the hyphen in "compound-protocol" is causing the problem, but the only advice I've gotten on how to fix that is to put the whole path in quotes, which I've already tried.
I've even tried navigating to the script folder within the terminal and running the test from there. While it does let me navigate into the script folder, trying to run the test produces a > Program 'test' failed to run: No application is associated with the specified file for this operationAt line:1 char:1. > error message.
Does anyone know how I might go about fixing this?
have you tried to use yarn install first? Also you need to use Node.js version 12 with that repository. NVM is a great tool to quickly switch between versions of Node on the command line. https://nvm.sh

I deleted npm but its still there

I want to delete npm from my system and start with a clean slate. So I run sudo apt remove npm.
Now, I called npm -v and it returned 6.13.7.
What dose that mean? is it possible that I have two or more installations of npm on my system? which one is considered "global"?
If I run whereis npm I get /usr/local/bin/npm and ls over there tells me its a soft link that points to /usr/local/lib/node_modules/npm
Should I simply rm * the folder and the link?
OK, took my risk and rm'ed the library and link. I did the trick. Now calling whereis npm returns an empty list and npm -v returns an error message.
So it probably was a path problem caused by improper installation process for node and npm in the first place.

How to fix timeout for packages on `npm install`?

When I run npm install it seems to work fine until part way installing packages. It seems to have no problem with the first half, but then after a while it will fail to be able to reach other packages. I just get the repeating errors, eg:
npm http request GET https://registry.npmjs.org/react-hot-loader
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-tap-event-plugin
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-test-renderer
etc.
It will continue to do this for an hour and and then the install will fail.
The install breaks at a different package each time so I don't think it's a problem with a particular file.
I can access these files fine with my browser and curl.
My work has a firewall but this domain is whitelisted.
Would anyone know what I could do to get this to work or what could be causing it?
If it's about the timing problem you should find a speed solutions for npm install.
So you can try these faster command than npm install :
pnpm install %70 faster
or
npm install --no-audit 15% faster
or
npm install --prefer-offline --no-audit 15% faster
check this article for details : speeding up npm install
You can override the max and min timeout in ~/.npmrc.
// npm config ls -l
// add these 2 lines in ~/.npmrc
fetch-retry-maxtimeout = 6000000
fetch-retry-mintimeout = 1000000
If your internet connection is the problem, try increasing the timeout:
npm config set timeout 6000000
The value is a 32-bit int.
If it's still relevant or maybe for other people of interest: For me it helped, deleting the package.lock file and running npm cache clean --force.
It might not be your case, but I had issues with a package being hosted at github with the repo url being only with git protocol (port 9418 not usually open on firewall).
Once added that to the firewall I could npm install without issues.
You can view the repository url with:
$ npm view zone.js repository.url
git://github.com/angular/angular.git
I saw an answer earlier that can resolve your problem by overriding the max and min timeout in ~/.npmrc file, but some didn't understand how to do it.
First go to the nodejs folder - for me it's located at ( Y:\Program Files\nodejs )
Open the node_modules folder.
Then npm folder.
Select (.npmrc) file + right click and open it with any text editor you want.
Finally add these 2 lines and click Ctrl+S
fetch-retry-maxtimeout = 6000000
fetch-retry-mintimeout = 1000000
.npmrc file after modification
npm cache clean --force
npm install --force
It works fine.
If you are on windows, try running vscode as administrator, it worked for me, I tried npm config delete https-proxy , npm config delete proxy and , tried deleting node_modules, and package.lock.json and ran npm cache clean --force but at last ran vscode as adminitrator before deleting node_modules and package.lock.json, it worked
I solved the timeout issue by executing these commands:
rm package-lock.json
npm i

npm install node-inspector always suspends

I recently study node and try to use npm to install node-inspector globally. But it always suspends here as following pic
I have changed the registry config for times, but it still doesn't work. Anyone can help? TAT
When npm install is stuck, you can increase verbosity of the output from install.
npm config set loglevel verbose
npm install -g node-inspector
Setting the log level to verbose will output a LOT of information. Based on the output you can find out where the errors/warnings are occurring and resolve them.
If git protocol is somehow involved and git's port is being blocked (TCP 9418), you could use https by doing
git config --global url.https://github.com/.insteadOf git://github.com/
npm install -g node-inspector
As you mentioned, you could use cnpm. Feel free to write your own answer and accept that one since that solved your problem.