Angular2 Quickstart lite-server crashes - node.js

Good Morning people from the Internet,
Intro
While following the Angular2 Quickstart guide I have experienced many times issues where lite-server would crash just after executing npm start. Crash would look like this in your terminal:
ERR! Linux 3.19.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "lite"
npm ERR! node v5.7.0
npm ERR! npm
v3.8.2
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart#1.0.0 lite: `lite-server`
npm ERR!
Exit status 1
npm ERR!
npm ERR! Failed at the angular2-quickstart#1.0.0 lite script 'lite-server'.
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 angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR!
Tell the author that this fails on your system:
npm ERR! lite-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/oscar/dev/cw/npm-debug.log
Most common reasons (and solutions)
Most of the time the reason was one of the two:
lite-server was not shutdown properly. Solution: Killing all npm / node instances and restarting the server with npm start would do the trick.
dependencies are not up to date. Solution: simply deleting the node_modules directory, executing npm install to rebuild the dependencies would do the trick.
Other issue
However when reaching the step called 6.Routing the issue was a bit different. This time instead of crashing straightaway it was failing after typescript compilation:
16.03.15 16:33:49 200 GET /index.html
events.js:154
throw er; // Unhandled 'error' event
^
Error: watch node_modules/angular2/es6/prod/examples/platform/dom/debug/ts/debug_element_view_listener ENOSPC
at exports._errnoException (util.js:856:11)
...
at FSReqWrap.oncomplete (fs.js:82:15)

I have found the cause of the crash. And I felt like sharing the path so it might help others because there are many forum / stackoverflow threads around the same sort of issue but none solved this crash.
Basically, I looked at the stack trace to find which "module" was failing. Here it is
at FSReqWrap.oncomplete (fs.js:82:15)
and the solution was to execute the following command (see this ticket):
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
but instead of just executing it, I needed to understand why setting to 524288 the config item fs.inotify.max_user_watches into /etc/sysctl.conf which is after a system file. I found the answer here where it says and I quote:
Nodejs would report an error if there's too many files for watching due to system limitation, on Linux you can change that by adding fs.inotify.max_user_watches = 524288 to the file etc/sysctl.conf and restart the process
Hope it helps.

Related

Why has my server stopped working after trying to install SCSS?

Currently, I am following a course in React development. As a part of the course, we have to install SCSS to style an e-commerce app. So far, I have tried avoiding SCSS and reformat the code to CSS. However, since there is no $ SCSS equivalent in CSS, I am forced to install SCSS. Nevertheless, after writing
npm add node-sass
I had to restart my server and I got the error stated at the end. In the course, they mention that there might be some bugs and in that case, we should use the following lines
rm -rf npm.lock
rm -rf node_modules
Despite using these lines, my server still will not start and I am still stuck being unable to proceed since I need SCSS to work, and for that, I need my server to work because I need to restart it to install NCSS. In the following lines, I will leave the error message I get when I try to start my server. npm and node are already installed.
aaronserpilin#Aarons-MacBook-Air crown-clothing % npm start
> crown-clothing#0.1.0 start /Users/aaronserpilin/crown-clothing
> react-scripts start
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! crown-clothing#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the crown-clothing#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! /Users/aaronserpilin/.npm/_logs/2021-10-02T13_22_23_006Z-debug.log
aaronserpilin#Aarons-MacBook-Air crown-clothing %
what your node-sass version used?
i used node-sass#4.14.1 and react#17.0.0 is work

react-scripts: command not found (npm start)

I've been using create-react-app without issues for some time, but recently, after running it, I cannot start the development server. After running npm start, I get the following error:
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! js-calculator#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the js-calculator#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Scripts appear to be in the correct location and correctly configured in the package.json file.
Also, npm start throws me the same error if I run it in other react-apps folders that used to work before.
I tried various suggestions I found here on stackoverflow:
installing create-react-app globally;
reinstalling dependencies (npm install);
reinstalling react scripts (npm install react-scripts --save);
updating node and npm;
but none of the above worked.
Any suggestions?
I've also a more detailed .log file, in case anyone wants to have a look at it.
After many tries and more reading of related issues here on SO, I found the cause. One of my react-app parent folders (five levels above) name was "example/example"; naming it to "example-example" solved the problem.

What does the ELIFECYCLE Node.js error mean?

What does ELIFECYCLE mean?
Here's my app code: https://gist.github.com/samholmes/388ca4552c5936b52c5d
When I run the 'blast-emails' command, it will run for a while until shortly crashing with the error:
npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nvm/versions/io.js/v1.6.1/bin/iojs" "/root/.nvm/versions/io.js/v1.6.1/bin/npm" "run" "live"
npm ERR! node v1.6.1
npm ERR! npm v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! emailer#0.0.0 live: `NODE_ENV=production node app.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the emailer#0.0.0 live script 'NODE_ENV=production node app.js'.
npm ERR! This is most likely a problem with the emailer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls emailer
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /apps/emailer/npm-debug.log
The npm-debug.log file is also included in the gist.
I'm looking for one of two answers: What does ELIFECYCLE mean? (or) Why am I getting the error in my application code?
It's basically saying it fails to spawn your process not due to permission but to an error in your script. Source
You don't have any problem executing NODE_ENV=production node app.js ?
One might think this is because outdated versions of npm and node, but it's not the case.
Just as Pierre Inglebert says, if you look into the source you can see that End of lifecycle means the program unexpectedly stopped. This can have various reasons. So it's not a syntax error and not an expected exception/error.
The error appeared to me when a different tool was already using the http port (3000) defined in my node scripts. When you run your node app on port 80, make sure you have stopped Apache webserver (as an example).
In my case, it was because of low RAM memory, when a photo compression library was unable to process bigger photos.
While working on a WordPress theme, I got the same ELIFECYCLE error with slightly different output:
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/7.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.6.0
npm ERR! npm v3.7.3
npm ERR! code ELIFECYCLE
npm ERR! foundationsix#1.0.0 postinstall: `bower install && gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foundationsix#1.0.0 postinstall script 'bower install && gulp build'.
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 foundationsix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install && gulp build
After trying npm install one more time with the same result, I tried bower install. When that was successful I tried gulp build and that also worked.
Everything is working just fine now. No idea why running each command separately worked when && failed but maybe someone else will find this answer useful.
If you came here like I did, after receiving a similar error when trying the React Getting Started guide, you might like to know that the problem could have been caused by not having installed Watchman. Download it here, or install it with Homebrew with brew install watchman and try again: https://facebook.github.io/watchman/docs/install.html
PS: You might want to do a brew update first.
When running Webpack build I was getting similar error because node doesn't understand async await keywords on older versions. I added webpack babel-plugin-transform-async-to-generator and it was solved. This replaces them with promises.
at process._tickCallback (internal/process/next_tick.js:10
4:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ng-contact-manager#0.0.0 sample: `node src/server/dat
a/seed-db.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng-contact-manager#0.0.0 sample script.
npm ERR! This is probably not a problem with npm. There is lik
ely additional logging output above.
npm ERR! A complete log of this run can be found in:
I have the same issue here is how I got solved finally!
the error:
my error from the terminal when i run npm run sample
after correcting my database connection username and password
I was using mlab for my database and under the file .env i forget to properly put the user name and password. When I correct that I works.
> ng-contact-manager#0.0.0 sample /Users/mohammedr.kemal/Downl
oads/Ex_Files_ANGULAR_API_AUTH/Exercise Files/Ch01/01_04/start
> node src/server/data/seed-db.js
connected to mongodb...
connected to mongodb...
2 records inserted.
closing connection...
done.
12 records inserted.
closing connection...
done.
So it might be good to look any data connection we made in our code if we have.
I had the same error after I installed new packages or updated them:
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
...
It helped me to run installation command once again or a couple of times.
After that, the error disappeared.
I had this issue when I was running two projects that had the same set up and I already had one running. This meant that the other project couldn't use that port number. As soon as I stopped the other project running I had no issues.
This issue can also occur when you pull code from git and not yet installed node modules "npm install".
The Windows solution is the same as the Linux sudo answer. Run the npm start (or whatever) as Administrator. I had added a new module to my project. Worked on some machines but on others that were more locked down, not so much. Took a while to figure it out but the new module needed access to "something" that wasn't available without administrator permissions.
I had the same error code when I was running npm run build inside node docker container.
Locally it was working while inside a container I had set option to throw error when there is a warning during compilation while locally it wasn't set. So this error can mean anything that is connected with stopping the process being done by NPM
In my case I generated a similar error when I copied the project over from another directory. some hidden files, like the critical .babelrc, were missing. SO ahhh... make sure you copy all the files!
:)
For me it was a ternary statement:
It was complaining about this line in particular, about the semicolon:
let num_coin = val.num_coin ? val.num_coin || 2;
I changed it to:
let num_coin = val.num_coin || 2;
Likewise, I saw this error as a result of too little RAM. I cranked up the RAM on the VM and the error disappeared.
I found the solution here - https://javahowtos.com/guides/124-docker/418-npm-exit-status-137-when-building-a-docker-image.html
It says - The cause of this specific npm error status usually means that Docker is going out of memory. So, when this happens, the Linux kernel just kills the process.
if you are running on ubuntu, please check your nodejs version. please update the version to the latest and clear the cache and reinstall the modules (npm install) and build.
or otherwise
please upgrade your RAM size and try again. it'll work sure.
First, you will have to remove the npm cache and upgrade to the latest version of the node and npm will resolve the issue.
sudo npm cache clean -f
sudo npm install -g n install n
sudo n stable
The first command will force clean the npm package manager's cache, After the second and third commands, a stable version of the node and npm will be installed. then you can execute npm i and npm run build for creating an optimized production build.
This solution worked for the same error on the npm run build command in nextjs.

npm install: 'bower install' exited with error code 1

I want to programm widgets for XBee ZigBee Cloud Kit.
To do it, I need first to set up everything.
I'm using this guide.
After failing repeatedly the automated setup I started the Manual setup. I did install the Requirements. So everything so far went good until the last point: npm install. I'm getting the following error bower install' exited with error code 1. I'm not sure what to do, I'm not used to PowerShell or any other shell.
After failing the installing I get this errors:
bower justgauge#* ECMDERR Failed to
execute "git ls-remote --tags --heads git://github.c
om/oscarcv/justgage.git", exit code of #128 fatal: remote error:
Repository not found.
Additional error details: fatal: remote error: Repository
not found.
'bower install' exited with error code 1
npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i nstall"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! xbee-zigbee-cloud-kit#1.0.0 postinstall: node postinstall.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xbee-zigbee-cloud-kit#1.0.0 postinstall script 'node postinstall.js'.
npm ERR! This is most likely a problem with the xbee-zigbee-cloud-kit package,
npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system:
npm ERR! node postinstall.js npm ERR!
You can get their info via:
npm ERR! npm owner ls xbee-zigbee-cloud-kit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\steim\Desktop\XBeeZigBeeCloudKit-master\npm-debug.log
"This is most likely a problem with the xbee-zigbee-cloud-kit package"
If this is true, in that case I don't know what to do, because I work with this package.
This is the npm-debug.log. (Sorry I can't post the whole log, too many characters).
I'm using a company laptop:
Latitude D820
Windows 7 32 Bit
Windows PowerShell with Administration
I'm grateful for any kind of help. I'm getting headache trying to figure it out.
I could solve it. And can now run the app now localy.
I did this steps to solve the issue:
Deleting justgage in bower.json file.
Using commandline: bower install justgage-official
Using commandline: bower update
The only problem is actually I can't start with foreman start (but it's another issue), instead I use python manage.py runserver 0.0.0.0:5000. After that in browser: http://localhost:5000
Thanks Etan Reisner for the hint and thanks Oscar Costoya for guiding me.

Error starting NPM .. Ghost Blog .. error npm start

********** Update *********
This had to do with me changing my ports to those of my ipaddress in config.js so I can test on mobile and table. Any idea how I can do this without changing the ports everytime I reboot the computer so that they are always set to my ipaddress for testing?
**********Original Question ****
I am getting a strange error when starting npm to run my ghost blog. It has happened before and I went back to a previous commit on github. It seems like everytime I get it working through a different method and then stop working and close terminal. Then when I restart its another issues?? Maybe github is causing it. Any help would be great. Tried everything I know how to do.
here is the error message:
cconti77#Charless-iMac ~/sites/_repos/elite-university (get-back-on-it●●●)$ npm start
ghost#0.5.0 start /Users/cconti77/Sites/_repos/elite-university
node index
Migrations: Up to date at version 003
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1023:19)
at listen (net.js:1064:10)
at net.js:1146:9
at dns.js:72:18
at process._tickCallback (node.js:419:13)
at process._tickFromSpinner (node.js:394:15)
npm ERR! ghost#0.5.0 start: `node index`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the ghost#0.5.0 start script.
npm ERR! This is most likely a problem with the ghost package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index
npm ERR! You can get their info via:
npm ERR! npm owner ls ghost
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/cconti77/Sites/_repos/elite-university
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/cconti77/Sites/_repos/elite-university/npm-debug.log
npm ERR! not ok code 0
You are already using the Ghost port for something else.
Most probably ghost exited the wrong way, or you are using forever/pm2 and the process hasn't closed properly. try killing any 'forever/pm2' instances, then reboot your machine. Worked for me.
To understand what happens, I suggest you try the following to see which process uses the ghost port, then kill the process. http://www.cyberciti.biz/faq/what-process-has-open-linux-port/
And also, you're a bit off-topic, this should be moved to SuperUser.

Resources