Npm not running in your new project? Here's what I learned

#1

Hi guys,

so I made a new repository on GitHub, a private repository, to start working on a new project.

In class we saw a really nice tool called NPM, which stands for Node Package Manager.

All I had about it was the command: npm start

I thought that I just had to run that command on the Terminal once I was on the Folder of my new project.

It turned out not to be the case. Why?

Because for every project you make, before doing the “npm start” command, you first have to initialize npm.

So the first command in your new folder would be:

npm init

Then that will create a package.json file on that folder. Once you have the correct setup on the package.json file then you just have to go to the next command:

npm install

You have to run this command every time the package.json file changes. That will install the new dependencies in it. It’ll grow over time.

Once all of this is ready you can just type:

npm start

and that should give you two IP addresses.

The first one is for you local computer;
the second one is for you to get into the index.html file or whatever you are working on from any other device on your local network.

Kevin Colten gave me this info and links if anyone needs more info:

  • npm init you only do once to generate the file, you can add packages to it with npm install package-name --save , and you can install all the packages listed in it with npm install . npm start ` is a custom script you can choose to write

  • all packages can be found at https://npmjs.org

1 Like