Angular 2, Node js Error npm run server:prod - javascript

I have an error trying to run the project in production,
When running npm run build: prod compiles me without errors, but when running npm run server: prod pass this:
C:\Users\Prueba Tecnica\Venfi> npm run server:prod
> venfi#3.3.0 server:prod C:\Users\Prueba Tecnica\Venfi
> http-server dist --cors
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:8080
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at Server._listen2 (net.js:1257:14)
at listen (net.js:1293:10)
at net.js:1403:9
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "server:prod"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! venfi#3.3.0 server:prod: `http-server dist --cors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the venfi#3.3.0 server:prod script 'http-server dist --cors'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the venfi package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! http-server dist --cors
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs venfi
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls venfi
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Prueba Tecnica\Venfi\npm-debug.log
Thanks for your help.

This is not node JS error,
Something is already running on Port 8080.
Kill that & run this again .!
Steps to kill a process on a port.
Type netstat -a -o -n and it will bring up a network list, look at the PID (e.g. 8080).
2 .To find out what PID 8080 was (hopefully not a trojan) I typed tasklist /FI “PID eq 8080″
To kill it type taskkill /F /PID 2600 [whatever processId i get in above step.]

Port is already in use. Just open your task manager on what ever OS you are on and kill any node processes. When using node stuff from the cli remember to kill the proccess by pressing ctrl + c when its running. Sometimes if you just close the terminal using X button it will close the terminal but leave the process running it the background. If all else fails and you can't get rid of the message just reboot the computer.

Related

Problem installing nodemon globally on macOS Mojave

In the Visual Studio Code terminal I issue to following command:
npm install -g nodemon
The result in terminal is:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ilkin/.npm/_logs/2020-08-30T16_39_29_236Z-debug.log
How can I solve it?
Use sudo before installing, it will ask for credentials enter it and done
sudo npm i - g nodemon
This means that you do not have root privileges / are not a superuser. You have two ways to solve this.
Use sudo before the command - this will usually then ask for credentials and run the command without a problem (hopefully)
Run sudo -s to automatically run commands with sudo every time in the current terminal window (will deactivate once the terminal has been closed)
Run sudo su which will make the computer think that the current terminal window has been opened by a root user (again will deactivate once current window has been closed)

Error running npm run serve on new vue project

I made this:
vue create myfirstapp
atom (for open my editor)
cd myfirst app
npm run serve
and I get this
> myfirstapp#0.1.0 serve /home/paolinsky/Documentos/vueBasico/fazt/myfirstapp
> vue-cli-service serve
INFO Starting development server...
10% building 2/2 modules 0 activeevents.js:196
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/public'
at FSWatcher.<computed> (internal/fs/watchers.js:168:26)
at Object.watch (fs.js:1351:34)
at createFsWatchInstance (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/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 (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/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: '/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/public',
filename: '/home/paolinsky/Documentos/vueBasico/fazt/myfirstapp/public'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myfirstapp#0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myfirstapp#0.1.0 serve 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/paolinsky/.npm/_logs/2019-12-15T15_13_50_223Z-debug.log
This always happen in all my vue projects, included the new ones.
My versions are:
npm: 6.13.4
node: v13.3.0
I'm running Ubuntu 18.04 on an asus vivobook laptop
4gb ram, Intel core I3 7th gen
I ran into this same problem recently. I solved it like this:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
cat /proc/sys/fs/inotify/max_user_watches
fs.inotify.max_user_watches=524288

npm install fails with message "Error: socket hang up"

I met this problem when execute the npm install module-name --save
It fails no matter what I install.
And it fails if I specified it in the package.json . and then run the npm install for the whole project.
There are some similar question posted like
NPM doesn't install any modules: network socket hangs up
NodeJS - What does "socket hang up" actually mean?
but unfortunately, it doesn't work for me. Also, npm install is OK with my other projects.
My environment: npm v6.4.1, node.js v10.10.0 serverless v1.28.0
Appreciated for the help of any kinds.
Here is my log message in my console:
> spawn-sync#1.0.15 postinstall /Users/pro/node_modules/spawn-sync
> node postinstall
> serverless#1.28.0 postinstall /Users/pro/node_modules/serverless
> node ./scripts/postinstall.js
Error: socket hang up
at createHangUpError (_http_client.js:322:15)
at TLSSocket.socketOnEnd (_http_client.js:425:23)
at TLSSocket.emit (events.js:187:15)
at TLSSocket.EventEmitter.emit (domain.js:442:20)
at endReadableNT (_stream_readable.js:1092:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm WARN cognito-backend#1.0.0 No description
npm WARN cognito-backend#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! serverless#1.28.0 postinstall: `node ./scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serverless#1.28.0 postinstall 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:
I found a github issue that solves my problem:
https://github.com/maciejtreder/ng-toolkit/issues/448
use nvm install v10.6.0

Can't run npm install without sudo. Setting permissions to .npm didn't work

Im running Ubuntu 14.04 and have installed nodejs from the ppa https://launchpad.net/~chris-lea/+archive/ubuntu/node.js. When ever I try to run npm install it gives an error like this : (running the command npm install -g generator-ember)
npm ERR! Error: EACCES, unlink '/usr/lib/node_modules/generator-ember'
npm ERR! { [Error: EACCES, unlink '/usr/lib/node_modules/generator-ember']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/generator-ember' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.13.0-37-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "generator-ember"
npm ERR! cwd /home/pubudu/Projects/techpro-yeoman
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/lib/node_modules/generator-ember
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/lib/node_modules/generator-ember'
npm ERR! error rolling back Error: EACCES, unlink '/usr/lib/node_modules/generator-ember'
npm ERR! error rolling back { [Error: EACCES, unlink '/usr/lib/node_modules/generator-ember']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/lib/node_modules/generator-ember' }
npm ERR! not ok code 0
I tried setting the permissions like this : sudo chown -R yourusername ~/.npm but it didn't work. How can I fix this? I can run npm with sudo but if I do, later im running into permission problems like when using grunt.
I had manies an issue with this too.
Changing the ownership of ~/.npm isnt enough because you are also getting access issues in /usr/lib/node_modules/ folders. You can change permissions here too if you like but changing permissions on folders is not recommended. If you were to change permissions on these folders too only do it on the folder you need ie the node_modules folder. Or you could go a different, more preffered, route -
Originally I went in and changed permissions of folders and all of that jazz but when I upgraded my system I used NVM.
From the ember-cli page, the link below leads to a tutorial about how to use npm and nodejs without using sudo by using node version manager:
http://www.wenincode.com/installing-node-jsnpm-without-sudo/
Once you have installed nvm as the tutorial above or as the github page tells you then whenever you log into a new shell you just use the command:
nvm use 0.10
where 0.10 is the version of nodejs you want to use.

Can't install js-bson

I am using Windows 7 64bit, trying to install bson as a dependencie of mongodb.
I get this error:
npm WARN package.json Wochenplaner#0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/bson
npm http 304 https://registry.npmjs.org/bson
bson#0.1.5 install C:\Users\Administrator\Dropbox\Projekte\Wochenplaner\node_m
odules\bson
node install.js || (exit 0)
CreateProcessW: Das System kann die angegebene Datei nicht finden.
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'C:\Users\Administrator\Drop
box\Projekte\Wochenplaner\node_modules\bson'
npm ERR! error rolling back bson#0.1.5 { [Error: ENOTEMPTY, rmdir 'C:\Users\Adm
inistrator\Dropbox\Projekte\Wochenplaner\node_modules\bson']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: 'C:\Users\Administrator\Dropbox\Projekte
\Wochenplaner\node_modules\bson' }
npm ERR! bson#0.1.5 install: node install.js || (exit 0)
npm ERR! cmd "/c" "node install.js || (exit 0)" failed with 127
npm ERR!
npm ERR! Failed at the bson#0.1.5 install script.
npm ERR! This is most likely a problem with the bson package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js || (exit 0)
npm ERR! You can get their info via:
npm ERR! npm owner ls bson
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "bson"
npm ERR! cwd C:\Users\Administrator\Dropbox\Projekte\Wochenplaner
npm ERR! node -v v0.8.16
npm ERR! npm -v 1.1.69
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\Administrator\Dropbox\Projekte\Wochenplaner\npm-debug.log
npm ERR! not ok code 0
I get this log: http://pastebin.com/B6F2C5um
What is the problem?
Also: I tried to install versions 0.1.1, 0.1.2, 0.1.3 etc.
I was having the same exact issue and remembered I had fiddled with my PATH variable, recently. It was failing to run cmd.exe.
It was fixed after adding c:\windows\system32 to my PATH.
Per below (note the node issue mentions socket.io, which was also causing similar problems when I tested it):
https://github.com/joyent/node/issues/4222
Try deleting C:\Users\Administrator\Drop
box\Projekte\Wochenplaner\node_modules and reinstalling.
I just installed the bson package on my Win7 (64bit also) box without any issues.
Check the following points.
Is your node executable accessible from everywhere? (check with opening a command line and just type node + Enter, if a shell pops up you should be fine)
Do you have sufficent access rights for the target folder in question?
Since the main error seems to be CreateProcessW: Das System kann die angegebene Datei nicht finden., i'm pretty sure the first point is the issue.
You could fix that easily by either re-installing node.js or adding the path to your node executable manually to the PATH environment variable.

Categories