npm fails out of the network - node.js

I have a trouble with npm, when I'm connected in my net it works nicely, but then I disconnected the computer, it stop working. When I run any command npm related, it fails giving me this error. Does anyone knows what's going on in there?
I have a Mackbook pro with Capitan OS
webpack-dev-server --config ./webpack/webpack.config.js --content-base ./app/ --watch --hot --inline --progress
70% 4/4 build modulesevents.js:141
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! frontend#1.0.0 dev: `webpack-dev-server --config ./webpack/webpack.config.js --content-base ./app/ --watch --hot --inline --progress`
npm ERR! Exit status 1
Thanks in advance.

This is the key to find the solution:
Error: getaddrinfo ENOTFOUND localhost
I went to my /etc/hosts file and I notice that localhost was not there anymore.
Add this line:
localhost 127.0.0.1
Everything is fine now.

Related

How to resolve these errors form updated Node & npm versions ..?

I update the Node latest version to 15.0.1 & npm 7.0.3. After i installed node modules and run my project with npm start its showing these type of errors....
cross-env NODE_ENV=development webpack-dev-server --open --config webpack.dev.js
node:events:304
throw er; // Unhandled 'error' event
^
Error: spawn webpack-dev-server ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:269:19)
at onErrorNT (node:internal/child_process:465:16)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:275:12)
at onErrorNT (node:internal/child_process:465:16)
at processTicksAndRejections (node:internal/process/task_queues:80:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn webpack-dev-server',
path: 'webpack-dev-server',
spawnargs: [ '--open', '--config', 'webpack.dev.js' ]
}
npm ERR! code 1
npm ERR! command failed
npm ERR! command sh -c cross-env NODE_ENV=development webpack-dev-server --open --config webpack.dev.js
npm ERR! A complete log of this run can be found in:
npm ERR! /home/krishnasai/.npm/_logs/2020-10-28T09_44_19_855Z-debug.log
feels to me that you installed cross-env globally, and it might break whenever you switch node versions.
i would advise you to have cross-env in the dependency of your project. you can do that by installing cross-env and specify that you would like to save it in your package.json.
try this
npm install --save-dev cross-env
then try again to run your project.

Failed to install npm dev / npm watch for Laravel 5.6

I'm working on a project in Laravel 5.6, I've installed npm successfully, but when I run npm run dev or npm run watch, I get this error:
$ npm run dev
> # dev C:\wamp64\www\QuAn
> npm run development
> # development C:\wamp64\www\QuAn
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
11% building 9/14 modules 5 active ...elector.js?type=template&index=0!C:\wamp64\www\QuAn\resources\assets\js\components\ExampleComponent.vue{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
78% module and chunk tree optimization unnamed compat pluginC:\wamp64\www\QuAn\node_modules\webpack\lib\Chunk.js:861
throw new Error(
^
Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
at Chunk.get (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Chunk.js:861:9)
at C:\wamp64\www\QuAn\node_modules\←[4mextract-text-webpack-plugin←[24m\dist\index.js:176:48
at Array.forEach (<anonymous>)
at C:\wamp64\www\QuAn\node_modules\←[4mextract-text-webpack-plugin←[24m\dist\index.js:171:18
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\node_modules\←[4mtapable←[24m\lib\HookCodeFactory.js:33:10), <anonymous>:12:1)
at AsyncSeriesHook.lazyCompileHook (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\node_modules\←[4mtapable←[24m\lib\Hook.js:154:20)
at Compilation.seal (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compilation.js:1342:27)
at C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compiler.js:675:18
at C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compilation.js:1261:4
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\node_modules\←[4mtapable←[24m\lib\HookCodeFactory.js:33:10), <anonymous>:31:1)
at AsyncSeriesHook.lazyCompileHook (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\node_modules\←[4mtapable←[24m\lib\Hook.js:154:20)
at Compilation.finish (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compilation.js:1253:28)
at C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compiler.js:672:17
at eval (eval at create (C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\node_modules\←[4mtapable←[24m\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
at C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compilation.js:1185:12
at C:\wamp64\www\QuAn\node_modules\←[4mwebpack←[24m\lib\Compilation.js:1097:9
←[90m at processTicksAndRejections (internal/process/task_queues.js:75:11)←[39m
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development 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\INFO\AppData\Roaming\npm-cache\_logs\2019-09-20T21_53_25_570Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev 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\INFO\AppData\Roaming\npm-cache\_logs\2019-09-20T21_53_25_604Z-debug.log
I've tried to clean the cache, delete node_modules, files and reinstall npm but nothing seems to resolve the problem.
Versions : Laravel 5.6 , Node 12.10 , npm 6.11.3
I think this solution will help you github Read JeffreyWay comment
Try doing a full reset:
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

How to fix cross-env issue when running "npm run dev" for vue-cli

When I run npm run dev, I can not get the local IP properly.
Error: listen EFAULT: bad address in system call argument 0.0.0.0:8081
I do.
1. delete the "cross-env" folder and the "cross-spawn" folder under the node_modules
2. run npm install
3. run npm run dev
4. the error ip changes as follows.
Error: listen EFAULT: bad address in system call argument 10.0.75.1:8081
the ip address is vEthernet for the docker.
PS E:\WorkSpace\my-project> npm run dev
> my-project#1.0.0 dev E:\WorkSpace\my-project
> cross-env NODE_ENV=development webpack-dev-server --open --hot
E:\WorkSpace\my-project\node_modules\webpack-dev-server\bin\webpack-dev-server.js:356
if (err) throw err;
^
Error: listen EFAULT: bad address in system call argument 10.0.75.1:8081
at Server.setupListenHandle [as _listen2] (net.js:1279:14)
at listenInCluster (net.js:1327:12)
at doListen (net.js:1460:7)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project#1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project#1.0.0 dev 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\LG\AppData\Roaming\npm-cache\_logs\2019-06-11T13_23_46_070Z-debug.lo
What if you try this:
yarn remove webpack-dev-server
yarn add webpack-dev-server#2.9.1 --dev
yarn run dev
or using npm instead yarn

npm start fail today with following error

when I test my code today at react, I fail to start the dev server, and the error shows as blow.
material#2.0.0 start /Users/linyujie/Files/Softprofiles/SourceCode/successmanagerreact
npm run serve:dev
> material#2.0.0 serve:dev /Users/linyujie/Files/Softprofiles/SourceCode/successmanagerreact
> webpack-dev-server --host 0.0.0.0 --port 3000 --open --env dev
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:3000
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at doListen (net.js:1501:7)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:678:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! material#2.0.0 serve:dev: `webpack-dev-server --host 0.0.0.0 --port 3000 --open --env dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the material#2.0.0 serve:dev 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! /Users/linyujie/.npm/_logs/2018-06-25T04_55_36_232Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! material#2.0.0 start: `npm run serve:dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the material#2.0.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! /Users/linyujie/.npm/_logs/2018-06-25T04_55_36_255Z-debug.log
The port 3000 is in use. Try to use netstat to find the PID of the process that is using the port. And stop/kill the process if you do not need it. This link might be handy for windows and this for mac to find the process listening on the port.
as the error said: Error: listen EADDRINUSE 0.0.0.0:3000, it means there is an application currently using the same IP & port: 0.0.0.0:3000. If you're not sure which application is using, maybe you can try closing all the command prompt and launch only your application.

Laravel-mix - BrowserSync throwing an error at event.js:160

Not sure if the problem is related to laravel-mix, but I am having problem with Browsersync package. Here is my mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
.browserSync({proxy: 'localhost:8000'})
.sass('resources/assets/sass/app.scss', 'public/css');
When I run npm run watch-poll ( watch doesn't pick up the changes, hence the watch-poll see here ) I get the following error on the console:
[Browsersync] Watching files...
events.js:160
throw er; // Unhandled 'error' event
^
Error: watch resources/views/auth/passwords ENOSPC
at exports._errnoException (util.js:1020:11)
at FSWatcher.start (fs.js:1443:19)
at Object.fs.watch (fs.js:1470:11)
at createFsWatchInstance (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleDir (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:407:19)
at FSWatcher.<anonymous> (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:455:19)
at FSWatcher.<anonymous> (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:460:16)
at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch-poll"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch 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/tanmay/.npm/_logs/2017-08-07T07_02_31_677Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # watch-poll: `npm run watch -- --watch-poll`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch-poll 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/tanmay/.npm/_logs/2017-08-07T07_02_31_725Z-debug.log
I am on: Ubuntu 16.04.3 (Not a VM). Running: Nodejs v6.11.2, NPM v5.3.0
When I comment out the .browserSync() call from my mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
// .browserSync({proxy: 'localhost:8000'})
.sass('resources/assets/sass/app.scss', 'public/css');
however, the error no longer persists. How do I get around the problem? Please feel free to ask any other necessary information.
Here is my package.json file
UPDATE: This error doesn't occur on a new laravel project. To get the same result as a new project, this is what I did:
I removed the node modules: rm -rf node_modules I removed the package-lock.json file: rm package-lock.json I re-run: npm install, npm run dev, npm run watch-poll
Result: still same error :(
This might be due to another task running on port 4040 already.
You can try killall -9 node
Source/more details: https://github.com/parse-community/parse-dashboard/issues/401#issuecomment-224007436
I suspect it's the same problem that is shown & with working solution from Gulp Error: watch ENOSPC
Try this: Why this issue occured? There is the limit in the number of
files that can be watched in a system. We have to increase this
number. The below command can be used to increase this number.
$ echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Resources