Node error npm ERR! cb() never called - node.js

When I am running the command npm install npm#latest -g
I am getting below error :-
npm WARN tar zlib error: unexpected end of file
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dk\AppData\Roaming\npm-cache\_logs\2018-04-10T03_25_52_880Z-debug.log
i googled it and tried so many things,nothing worked.

To anyone stumbling upon this question, if you are facing the same error message on npm install, then npm install --no-package-lock solved it for me.
As suggested in the referenced Github issue in Mohit Mutha's comment above, this is especially true if the command is ran in a CI/CD pipeline, or in my case, in Docker.
EDIT: Reason being is that the package-lock.json file already exists in your Docker image or CI pipeline
Full details

Our team encountered this error in our CI pipeline. However, the top answer of using --no-package-lock actually causes npm to also not use a present package-lock.json, which is definitely not the desired behavior for CI. Instead, using npm ci is now the recommended way to install in CI since it will use the existing package-lock (and nothing else).

Solved by running
sudo npm cache clean --force
and after that deleting package-lock.json and node_modules
and then performing
npm install

FYI I have gone through DOZENS of these responses for the exact same ask posted here again and again in SO. I think most of responses are valid. But in my case the actual issue was the CORPORATE PROXY not npm itself.
In my Dockerifle I had to explicitly add http-proxy and https-proxy to my npm config prior to running the npm install and it worked. FYI you need to tell npm config about your proxy or it wont download dependencies and this is what was throwing the cb() never called error - this works in both local (terminal) and docker containers.
...
RUN npm config set http-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm config set https-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm install
EXPOSE 3000
CMD ["node", "server"]

Related

npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! network Socket timeout

This the error:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
I have running: -npm cache clean --force
Deleted node_modules and lock-package.json and run npm install but still got me that error
Try this answer
or run npm i -g npm#8.5.1
i think it's an issue with npm version , 8.5.1 solves the problem in most cases
basically try earlier versions and i think the problem will be solved
I faced this error some days ago. I changed the timeout and it works for me. (Note: my npm version is 8.19.1)
You can try this solution with other npm versions as well.
First of all, check the current settings. For checking the current settings run npm config ls -l or grep fetch
Then, check these 4 values (fetch-retries, fetch-retry-factor, fetch-retry-maxtimeout, fetch-retry-mintimeout, fetch-timeout)
$ npm config ls -l | grep fetch
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
For changing the time out, Run these two commands-
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
I faced this problem recently. I tried many solutions like npm cache verify, npm cache clean --force, npm config set fetch-retry-mintimeout, npm config set fetch-retry-maxtimeout, deleting package-lock.json, using different version of npm and/or node.
But the solution that worked for me was to switch to yarn.
I solved this by setting a timeout of 60000 for npm in the .npmrc file. To do that from your terminal, simply do the following:
$ nano .npmrc from your work directory if you want a configuration locally.
Add timeout=60000, save and you're good to go.
Originally posted here: https://github.com/facebook/create-react-app/issues/10251
You can resolve this using YARN package manager. yarn create react-app my-app
hope it help.
I am not sure if this will help anyone else, but what appears to have worked for me was dropping my company's VPN connection and reestablishing it!
In my scenario, it was the yarn.lock file availability. So the installer tried to fetch dependencies and threw an error since the response time was delayed. So deleted both yarn.lock and package.lock file and reinstalled after setting npm to npm#8.5.1
I found solution for it, which works great for me
1.npm config set registry http://registry.npmjs.org/
2.npm i or npm i --save --legacy-peer-deps
Try removing proxy settings by running the commands below:
$ npm config rm proxy
$ npm config rm https-proxy
mine worked using these steps, hope it works for you too.
npm cache clean --force
npm uninstall -g create-react-app
npm uninstall create-react-app
and then
npx create-react-app project-app
if it does not then probably your internet connection is poor or there is a proxy set up error. let me know if it does not work.

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

iam getting below error with npm while creating react app
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log
my npm version is 8.1.4 and i solve this problem by running :
npm cache clear --force
I resolved it by deleting node_modules and package-lock.json and run npm install again.
solved with npm i --legacy-peer-deps on react-native version .70
Just run these 2 commands :
npm cache clear --force
npm install
Probably it's a project that works with Yarn and not NPM.
Try Yarn instead of NPM.
yarn install
and then you can do
yarn start
or
npm start
Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.
I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.
In my case the file .npmrc was corrupt. After deleting it everything worked.
I was getting the same error, but I was able to resolve it by the below described method:
Go to folder -> Local > npm-cache and delete all contents of the npm-cache.
try again with npm command, it should work now.
I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.
In my case i updated npm via:
npm update -g npm
After it, everything worked fine.
Don't know why, i didn't expect it.
I solved deleting node_modules and running this command:
npm cache clear --force

Vue CLI SOCKET_TIMEOUT error creating new project (npm error)

So basically I am trying to set up a new Vue project using vue create vue-first-app and I end up with this error below. I tried to increase the timeout using npm install -timeout=9999999 . I also tried cleaning the npm cashe with npm cache clean --force but it did not help. Does anyone know a way to solve this?
Vue CLI v4.5.9
✨ Creating project in /home/marius/vue/vue-first-app.
🗃 Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npm.taobao.org/mkdirp failed, reason: Socket timeout
npm ERR! A complete log of this run can be found in:
npm ERR! /home/marius/.npm/_logs/2020-12-14T09_54_21_447Z-debug.log
ERROR command failed: npm install --loglevel error --legacy-peer-deps
Try
Either:
sudo npm cache clean -f
npm update
npm update -g #vue/cli
vue create vue-first-app
OR
Point the npm registry url to http :
npm config set registry="http://registry.npmjs.org/"
And then re-run your vue cli command :
vue create vue-first-app
This may help you.
Check if you have a working internet connection (check if the firewall is not blocking the connection request)
Try to go the npm config file and change the time out from there. This issue is commonly caused when one of these two reasons occur. Path: installationDirectory\nodejs\node_modules\npm and open the .npmrc file and try changing the time out from there.
Also refer: https://docs.npmjs.com/common-errors
Had the same problem.
For me, using sudo worked.
sudo vue create vue-first-app
Good luck!
I had a similar problem, for me it worked changing the useTaobaoRegistry to false in the config .vuerc, it should be located on C:/User/your_name/
{
"packageManager": "npm",
"useTaobaoRegistry": false
}
Thanks to fangbinwei for the solution:
https://github.com/vuejs/vue-cli/issues/6003#issuecomment-716158880

error: This is probably not a problem with npm. There is likely additional logging output above

In my project, I'm using Angular6 for the frontend. Now what I'm trying to do is deploy my project which is in remote server into the actual server. I'm using npm run build -prod command to build the frontend first. But I can't build my project since the following error occurs again and again,
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! Trackit-Revamp#6.0.0 build: `ng build --prod --build-optimizer --aot`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the Trackit-Revamp#6.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Indrajith.E\AppData\Roaming\npm-cache\_logs\2019-08-22T08_41_00_271Z-debug.log
My error log in the C:\Users\Indrajith.E\AppData\Roaming\npm-cache\_logs\2019-08-22T08_41_00_271Z-debug.log file path contains the same error details mentioned above.
How can I resolve this problem?
Delete your package-lock.json file and node_modules folder.
Then do npm cache clean
npm cache clean --force
do
npm install
again and run
Finally, I found a solution to this problem without reinstalling npm and I'm posting it because in future it will help someone,
Most of the time this error occurs javascript heap went out of the memory. As the error says itself this is not a problem with npm. Only we have to do is
instead of,
npm run build -prod
extend the javascript memory by following,
node --max_old_space_size=4096 node_modules/#angular/cli/bin/ng build --prod
Please delete package-lock.json and clear npm cache with npm cache clear --force
and delete whole node_modules directory
Finally install or update packages again with npm install / npm update
You can also add any new packages with npm install <package-name>
This fixed for me.
Thanks and happy coding.
I'm on Ubuntu 18.04. I fixed this problem by increasing the inotify max_user_watches using this command:
echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
I'm new with react... Well i had the same output:
Starting the development server...
events.js:196
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/opt/lampp/htdocs/react-tuto/public'
at FSWatcher.<computed> (internal/fs/watchers.js:168:26)
at Object.watch (fs.js:1351:34)
at createFsWatchInstance (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:482:16)
at FSReqCallback.oncomplete (fs.js:165:5)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/opt/lampp/htdocs/react-tuto/node_modules/chokidar/lib/nodefs-handler.js:81:15)
[... lines matching original stack trace ...]
at FSReqCallback.oncomplete (fs.js:165:5) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/opt/lampp/htdocs/react-tuto/public',
filename: '/opt/lampp/htdocs/react-tuto/public'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-tuto#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-tuto#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/paulo/.npm/_logs/2019-12-16T16_46_27_856Z-debug.log
I just tried:
sudo npm start
And it worked.
I already have the same problem . and I fix it using npm update & npm cache clean --force
Delete node_modules
rm -r node_modules
install packages again
npm install
Delete node_module directory and run below in command line
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
If still not working, try below
npm install webpack --save
For me, the problem was in firebase.json, the site name was incorrect.
For the people it didn't work, I spent two days finding the solution and there was just one command that worked like a magic.
npm install -g live-server
and then run: npm start
it will start as normal.You can read all the details here https://www.npmjs.com/package/live-server
Deleting the package-lock.json did it for me. I'd suggest you not push package-lock.json to your repo as I wasted hours trying to npm install with the package-lock.json in the folder which gave me helluva errors.
Check if port you want to run your app is free. For me, it was the problem.
Following steps solves my problem:
Add "C:\Windows\System32\" to your system path variables
Run npm eject,
Run npm start,
Run npm eject,
and agian run
npm start
And it worked😊
For me, I was trying to install an old version of bcrypt which was not found in npm, I just edited package.json and manually put the latest version and then ran npm install and it worked
first delete the file (project).
then rm -rf \Users\Indrajith.E\AppData\Roaming\npm-cache_logs\2019-08-22T08_41_00_271Z-debug.log (this is the file(log) which is showing error).
recreate your project for example :- npx create-react-app hello_world
then cd hello_world.
then npm start.
I was also having this same error but hopefully after spending 1 day on this error i have got this solution and it got started perfectly and i also hope this works for you guys also...
I had encountered the same error. And, I just simply deleted the whole node_modules folder, and installed the npm packages again solved my error.
Delete node_modules (don't worry you have package.json)
npm install
Novice mistake. Make sure your package.json file is coded correctly. I had:
"start": "index node.js"
instead of:
"start": "node index.js"
17
Delete your package-lock.json file and node_modules folder. Then do npm cache clean
npm cache clean --force
do npm install
I just do two steps:
first:
export METEOR_ALLOW_SUPERUSER=true;
second:
sudo systemctl stop bbb-html5
and finally:
npm start
My project is on wagtail. I solved this problem by running the following command:npm update & npm cache clean --force
I had the issue in React. In my case it was happening, because I didn't see warnings/errors above the message. After fixing the issues, everything worked properly. Hopefully it's going to help someone.
On Ubuntu, I restarted the server and the problem was solved.
For me, it happens because of the low version of Node. Upload my Node version and it worked successfully.

Error installing Angular using npm due to require-from-string

How to resolve this error as I am not able to install Angular.
Please see the below exception:
C:\Users\absin\node>npm install -g #angular/cli
npm ERR! code ETARGET
npm ERR! notarget No matching version found for require-from-string#^1.1.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cosmiconfig'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\absin\AppData\Roaming\npm-cache\_logs\2018-01-06T19_07_00_000Z-debug.log
even after temporal solution:
npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm install
still getting this
as stated in the issue link:
temporal solution:
npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm install
UPDATE:
It appears they are working on it. The require-from-string page used to return a 404, but at least now it loads the correct page on NPM's website: https://www.npmjs.com/package/require-from-string
Still doesn't appear to be working through npm install yet.
UPDATE 2:
An official response from NPM: https://status.npmjs.org/incidents/41zfb8qpvrdj
UPDATE 3: issue seems to be resolved.
Even if https://status.npmjs.org/ says that it s all ok now,
the problem persist here
some problem with NPM registry some of the packages got deleted.
They are restoring it... it will be available shortly
Temp solution use the missing package from already running projects that or older projects.
I had the same issue. So when I used yarn it worked well and not having any problem to create new projects also.
yarn global add #angular/cli
again, when you create new app ng new newapp it will fail because at this moment npm is not able to find a package called require-from-string. But the you can run yarn to install all the packages. Yarn will ask which version of the require-from-string is needed. you can choose it.
npm is having issues. This should just work.
npm registry issue is now fixed according to https://status.npmjs.org/incidents/41zfb8qpvrdj
Solution
rm ./package-lock.json
git commit -am "Removed broken package-lock.json file."
git push heroku master

Resources