Angularjs tutorial - 'npm start' not working
I'm having problems with the "npm command" found at the end of the first step of the tutorial. I've overviewed the other threads on this question but haven't found the answers I'm looking for.
The project is cloned from github, Node is installed. I've confirmed this with
$ node --version v. 0.10.29 orienting myself to ../GitHub/angular-phonecat in Gitbash, I write
$ npm install npm WARN optional dep failed, continuing [email protected] |
[email protected] install c:..\Documents\github\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.ioclient\node_modules\ws (node-gyp rebuild 2> builderror.log) || (exit 0) \
Next step is
$ npm start
[email protected] prestart c:..\Documents\github\angular-phonecat npm install
Now, browsing to "localhost:8000/app/index.html" explained in the tutorial, i'm getting a 404-error message.
I guess that's not a correct output.. so just wondering if any of you guys have any suggestions where to go next?
What happens if you do the following?
npm install -g http-server
http-server
$ http-server Starting up http-server, serving ./ on port: 8080 Hit CTRL-C to stop the server
Works fine, the file structure is displayed
the tutorial has something wrong. the url you visite should be http://localhost:8080/app
Hello! I solved this problem with this steps (Windows):
1.- Go inside angular-phonecat with Windows cmd.exe (cd C:\bla\bla...\angular-phonecat).
2.- npm install
3.- npm install -g bower.
4.- bower install.
Well, this is the problem, "http://localhost:8000/app/index.html" doesn't work and we need to open it with "http://localhost:8080/app/index.html".
5.- Open angular-phonecat/package.json with text editor (sublime, notepad++, brackets, etc.).
6.- Change the "scripts"{"start"} option about line 22 This: "start": "http-server -a 0.0.0.0 -p 0000", That: "start": "http-server -a 127.0.0.1 -p 8080",
7.- npm start.
8.- Open browser with this url: "http://localhost:8080/app/index.html".
Now we need to run the tests. Close the server with CTRL+C:
9.- npm test. Check if ok.
10.- npm run update-webdriver (only once).
11.- npm start.
12.- npm run protractor.
Oups! protractor don't work :O. protractor opens "localhost:8000" and we need "localhost:8080" :(. No problem change the protractor config and everything will be ok :P.
Open this file with your text editor: "test/protractor-conf.js". Change baseUrl about line 14 This: baseUrl: 'http://localhost:8000/', That: baseUrl: 'http://localhost:8080/',
Finish, setup complete :).
This last comment helped me too. It looks like there's something running on 8000 on my Windows machine already, so changing the port to 8080 allow me to start the server.
its very helpful
I am also doing this tutorial and having issues. Changing to port 8080 solved one problem but now all I get is 'Not Found'. I have tried any number of paths, copied the path from Windows properties, but the server still gives 'Not Found'. Servers running fine, just cant figure this out.
Ran into a 'npm start' failure on MacOSX as well. Unlike the people commenting on Windows, my issue was making sure I ran the 'npm install' as specified in the tutorial as root.
Issue was fixed by doing a 'sudo npm install'.
i had to remove the public folder
just stayed with 0.0.0.0 and 8000
@eabdelmoneim I'm on OSX 10.10 and that worked! Thanks!
I had this problem as well. Running the http-server command directly rather then using npm start in terminal helped diagnose the issue. I'm on Ubuntu 14.04 LTS, nvm using node v0.12.2
$ http-server -a 0.0.0.0 -p 8000
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
The error name is fairly straight forward, E(rror) ADDR(ess) IN USE, so I tried the suggestion above and used http-server -a 127.0.0.1 -p 8080, and got the same error. So if that happens to you don't get discouraged. I then tried http-server -a 127.0.0.1 -p 5000 to no success and finally -p 3000, which turned out to be available and working.
I'm guessing 8080 is tied up because of apache but I don't remember node not being able to listen to 8080 on my last install before using nvm. Either way. Solution works, and If you are having same error code, keep trying until you find an open port. Then, to implement working solution, use @erknrio instruction, change the "start" property under "scripts" in the package.json file from "http-server -a 0.0.0.0 -p 8000" to "http-server -a 127.0.0.1 -p <the open port>".
...
},
"scripts": {
"postinstall": "bower install",
"prestart": "npm install",
"start": "http-server -a 127.0.0.1 -p 3000",
"pretest": "npm install",
Thanks @erknrio
**Edit**: You will have to do the same thing I believe for the module protractor-conf.js - set the proper localhost:port for the "baseUrl" property
Sometimes the port is tied up if you happen to leave a previous http-server or similar running in the background. You can find out on OS/X what the port is being used by if you run
lsof -iTCP:8080
Your welcome @mrosata :).
guys "npm test" does not work for me although "npm start " is working fine! it outputs the error describing that it can not find "socket.io-client". i'm using windows 7 by the way.
Those who have problem with live-server not opening a browser window just do "start": "live-server --open=src --port=3000 --host=127.0.0.1" in the script part of package.json.
How to use these? I am at step 0. how to change the code to step 1 and edit, do the practice. Kindly share if any vedios are there?
@erknrio Thank you very much for this solution :+1: This solution works on Ubuntu OS as well.
Thanks @sajedshaikh777, which version of Ubuntu are you using?
For windows 7, change to the Samples/Chapter01/live-server-test folder, and run these commands:
npm install
npm start
On my system the chrome browser (default) launches per the book.
@beacham npm start work for me..thanks