NPM - Can't install packages - node.js

I inherited a React project and after getting the latest code it failed to run - the previous developer isn't available. So, with no experience, I got on with it
Here's a list of the thing I did:
Updated Node to latest
Updated NPM to latest
Updated VS Code to latest
Removed package-lock.json
Ran a bunch of npm<whatever> commands that are littered all over internet
The coup de grâce was when I deleted all the packages from node_modules
So, now I can't even get npm install --verbose to work. It just hangs and gives no feedback. I can't reinstall Node because the jokers here got us locked-down.
What can I do to install the packages? Am I doomed?
UPDATE: I disconnected from the network and went on the company wifi and npm install worked. How can that be?

Due to your update - probably your machine is behind the company proxy, that's why npm cannot get packages. To fix this find your proxy address, and after this run in terminal:
npm config set proxy http://yourproxy.company.com:8080
npm config set https-proxy http://yourproxy.company.com:8080
I found this method on https://jjasonclark.com/how-to-setup-node-behind-web-proxy/, works very good.

Related

npm install always ETIMEOUT can's fix

I have spent my whole day on fixing this problem but can't see any light.
My node and npm version is below
And no matter what package I wanna install, it always show
I am sure that I am not in any proxy and I have already lower my node version from 18 to 14,
but the problem still exist!!!!
Could anyone know how to fix this problem help me?
I already tried every way to fix this but can't work.
Since when did the issue start? Did it occur after you installed any dependency or made any proxy / firewall related configurations?
However you can try one of the following ways to fix this issue
Delete node_modules folder and in terminal, write
npm install
Change your nodejs version, either upgrade it or downgrade it
Reinstall nodejs
Try some other package manager like yarn
Note: When changing your nodejs version, please ensure that your node version is compitable with the npm version
Edit:
If these solutions don't work, the error is most probably caused by network related issues, you can try the following fixes
In terminal, reset the registry path of your node package manager
npm config set registry http://registry.npmjs.org/
If you are using your organization's computer, you need to use a proxy, remember to change the proxy url and port as per your organization
npm config set proxy http://proxyurl.com:8080
npm config set https-proxy http://proxyurl.com:8080
Instead of local installation, try installing packages globally i.e
npm install -g mongoose
Clear the cache
npm cache verify
Switch your device to some other wifi network and then try installing some npm packages

npm "Invalid response body while trying to fetch". Can't install any dependencies using npm

Good day everyone! I recently got this message:
npm WARN config global --global, --local are deprecated. Use --location=global instead
I took care of this problem by editing the 4 necessary files (npm, npm.cmd, npx, npx.cmd).
Problem is, now I can't install any dependency and I can't use npx (for example for npx create-react-app my-app).
When trying to install a dependency
Running npx
What I have tried so far:
npm cache clean –force
npm chache verify
Deleted the npm-cache folder under 'C:\Users\reaga\AppData\Local\
Completely uninstalled Nodejs and reinstalled the LTS
Completely uninstalled Nodejs and reinstalled the current version
Changed the npm-cache folder's location using npm config set cache C:\reaga\nodejs\npm-cache --global
Deactivated antivirus
Prayed to 17 different gods
On the flip side yarn seems to be working so I have no problems running yarn add express for example. Any help would be very much appreciated!

npm does not support Node.js v12.18.3

Can see it's been asked a dozen times but none of the solutions I've found have worked for me so far.
I've installed the latest version of Node.js (12.18.3) on my Windows 10 PC and I'm trying to install a package using npm. When I input npm -v it comes back with 5.6.0, which to me looks out of date - but when I try and install a package or update npm, I get the following error every time:
npm WARN npm npm does not support Node.js v12.18.3
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.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
I've tried uninstalling Node.js completely, deleting all node_modules folders and restarting my computer after a fresh install, but it's the same thing each time. I've also tried using npm install -g npm and npm install npm#latest -g but again, I get the same error.
Any solutions here?
I found the work-around !
First you need to open your cmd line, and use " npm install -g npm#latest "
you'll get the error like this
C:\Users\KimeruLenovo>npm install -g npm#latest
npm WARN npm npm does not support Node.js v14.7.0
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.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function npm ERR! A complete log of this
run can be found in: npm ERR!
C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log
Go to the path where you can find the debug log( this file is found in your npm-cache folder)
C:\Users\KimeruLenovo\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node .
once deleted go back to your comand line and re-use the command
" npm install -g npm#latest "
This should do the trick :)
I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3.
The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": https://nodejs.org/en/download/).
This Github issue led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to C:\Users\{User}\AppData\Roaming and delete the npm and npm-chache folder and finally install node again (using the installer).
The problem on my end was arising because I was using NVM yet I had already previously installed NPM independently.
All I did to solve the issue was delete the npm and npm-cache folder located here:
C:\Users\your-username\AppData\Roaming. No need of doing a fresh npm install (just leave that to NVM)
I had the same problem. Delete node and npm cache in AppData folder inside C: drive and install recommended version on another drive.
Go to the path where you can find the debug log (this file is found in your npm-cache folder) C:\Users\yourname\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node. Once deleted go back to your command line and re-use the command " npm install -g npm#latest "
I had same issue.
I tried to install node with choco install -y nodejs.install.
then, npm i works fine.
(before that, nodist was uninstalled)
I used nodist to install node. it may be the cause I think.
I have the same problem even after reinstalling Visual Studio. Cleared caching, and the weird thing, the Node.Js which is installed is the lastest (12.18.3)
So far i've found the node modules of the npm package, in the troubleshooting file they were accuring this solution
"
You can check your npm version by running npm -v.
Steps to Fix
Upgrading on *nix (OSX, Linux, etc.)
(You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.)
You can upgrade to the latest version of npm using:
npm install -g npm#latest
Or upgrade to the most recent LTS release:
npm install -g npm#lts
Upgrading on Windows
We have a detailed guide for upgrading on windows on our wiki.
Proxy and Networking Issues
npm might not be able to connect to the registry for various reasons. Perhaps your machine is behind a firewall that needs to be opened, or you require a corporate proxy to access the npm registry. This issue can manifest in a wide number of different ways. Usually, strange network errors are an instance of this specific problem.
Sometimes, users may have install failures due to Git/Github access issues. Git/GitHub access is separate from npm registry access. For users in some locations (India in particular), problems installing packages may be due to connectivity problems reaching GitHub and not the npm registry.
If you believe your network is configured and working correctly, and you're still having problems installing, please let the registry team know you're having trouble.
Steps to Fix
Make sure you have a working internet connection. Can you reach https://registry.npmjs.org? Can you reach other sites? If other sites are unreachable, this is not a problem with npm.
Check http://status.npmjs.org/ for any potential current service outages.
If your company has a process for domain whitelisting for developers, make sure https://registry.npmjs.org is a whitelisted domain.
If you're in China, consider using https://npm.taobao.org/ as a registry, which sits behind the Firewall.
On Windows, npm does not access proxies configured at the system level, so you need to configure them manually in order for npm to access them. Make sure you have added the appropriate proxy configuration to .npmrc.
If you already have a proxy configured, it might be configured incorrectly or use the wrong credentials. Verify your credentials, test the specific credentials with a separate application.
The proxy itself, on the server, might also have a configuration error. In this case, you'll need to work with your system administrator to verify that the proxy, and HTTPS, are configured correctly. You may test it by running regular HTTPS requests.
"
I'll try to work on it and keep you informed if i'm able to solve this problem
Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm#latest "
This should do the trick :)
As mentioned earlier, is that I deleted these folders before installing the new version and also worked.
Start by uninstalling the node js by running npm uninstall -g npm, you will fall back to the previous version of Node.js
Just install what is required from the official site of Node.js https://nodejs.org/en/
No SO version or command lines required
If none of these solutions work which happened to me just go to https://nodejs.org/en/ and download the recommended version manually super fast!
Use n.
I am so glad discovered this package.
if npm installed;
npm install -g n
n lts
for other ways or more details;
https://www.npmjs.com/package/n
My specific case required that I use node 12.14 and I was getting this error.I tried installing the npm version but still was getting this issue
I was using NVM, so I uninstalled all other versions of node using
nvm uninstall 18 And like this all other versions
Before uninstalling the last version, I was getting some error so I ran
nvm deactivate
After which I uninstalled the last remaining node version too
I uninstalled the npm after that, and installed just the node version I needed using NVM
nvm install 12.14
and it installed the required npm too, with it my problem was solved. Hope this would be of use to someone

Undefined variable: "$font-weight-bolder" when running npm development server

In a vue project, that is worked on by a lot of people a recently started to get this error when running:
npm run dev
error when starting development server
When running npm install, I also get this warning which might be related to the problem:
npm WARN bootstrap#4.5.0 requires a peer of popper.js#^1.16.0 but none is installed. You must install peer dependencies yourself.
I believe this is happening since I updated my node version, but I'm not sure.
From my research this problem might be related to node-sass or the css-loader.
Details:
Windows 10 64bit
node version: 12.16.3
npm version: 6.14.4
What I've already tried
Completely uninstall node and reinstall it
Try different node versions with nvm (I always deleted node_modules and package.lock and ran npm install again)
Completely delete my git repository and start fresh
Delete node_modules and run "npm ci"
install the css loader
Other development environments work fine so it's most likely something specific with this repository and my machine but I don't really know how to find the problem.
And also, the environment was working fine for me a couple of days ago so it's not a general problem in this repository.

How can I install the latest version of Typescript without Internet (offline)?

I have Internet connection in my home and I can install the latest version of TypeScript with this command: npm install -g typescript , But unfortunately There is no Internet at my work place (in fact we are not allowed to use Internet).
Beside this I googled But It seems There is no offline installer for Typescript. My question is how can I handle this problem ?
I am totally new to npm and a step by step workaround would be appreciated .
There is an ugly solution: do npm install at home and copy the content of your globally installed packages folder to work.
If you want to be able to do npm install without access to the internet you will need to configure your own npm registry in your local network.
I've used Sinopia in the past when working offline. It works as a cache for npm allowing you to work off-line provided you have installed the required packages while having an internet connection.
As per https://www.npmjs.com/package/sinopia#installation you can install and configure Sinopia with the following steps:
# installation and starting (application will create default
# config in config.yaml you can edit later)
$ npm install -g sinopia
$ sinopia
# npm configuration
$ npm set registry http://localhost:4873/
# if you use HTTPS, add an appropriate CA information
# ("null" means get CA list from OS)
$ npm set ca null

Resources