angular-phonecat icon indicating copy to clipboard operation
angular-phonecat copied to clipboard

Angularjs tutorial - 'npm start' not working

Open lavalampan opened this issue 12 years ago • 24 comments

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?

lavalampan avatar Jul 01 '14 07:07 lavalampan

What happens if you do the following?

npm install -g http-server
http-server

petebacondarwin avatar Jul 01 '14 09:07 petebacondarwin

$ http-server Starting up http-server, serving ./ on port: 8080 Hit CTRL-C to stop the server

Works fine, the file structure is displayed

lavalampan avatar Jul 01 '14 10:07 lavalampan

the tutorial has something wrong. the url you visite should be http://localhost:8080/app

zztczcx avatar Jul 29 '14 08:07 zztczcx

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 :).

mrroot5 avatar Aug 04 '14 13:08 mrroot5

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.

kevinhooke avatar Sep 30 '14 22:09 kevinhooke

its very helpful

chintan0 avatar Oct 15 '14 00:10 chintan0

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.

ginblue avatar Dec 21 '14 15:12 ginblue

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'.

eabdelmoneim avatar Jan 25 '15 22:01 eabdelmoneim

i had to remove the public folder

just stayed with 0.0.0.0 and 8000

ukizhake avatar Feb 09 '15 16:02 ukizhake

@eabdelmoneim I'm on OSX 10.10 and that worked! Thanks!

JuanCarlosC avatar Jun 03 '15 04:06 JuanCarlosC

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

mrosata avatar Jun 06 '15 13:06 mrosata

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

petebacondarwin avatar Jun 06 '15 14:06 petebacondarwin

Your welcome @mrosata :).

mrroot5 avatar Jun 09 '15 10:06 mrroot5

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.

farskid avatar Jul 11 '15 16:07 farskid

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.

KaustubhKhati avatar Dec 07 '15 11:12 KaustubhKhati

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?

RajeswarReddy avatar Feb 19 '16 05:02 RajeswarReddy

@erknrio Thank you very much for this solution :+1: This solution works on Ubuntu OS as well.

ghost avatar Sep 22 '16 11:09 ghost

Thanks @sajedshaikh777, which version of Ubuntu are you using?

mrroot5 avatar Nov 30 '16 14:11 mrroot5

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 avatar Jan 24 '17 00:01 beacham

@beacham npm start work for me..thanks

vishalmule17 avatar May 25 '17 11:05 vishalmule17