ProtoTyPus ProtoTyPus - 2 months ago 17
JSON Question

NodeJS package.json



I'm setting NodeJS but when I run "connect", it says me that there is not "package.json".

I've installed NodeJS ->


$ npm install -g express-generator
$ npm install express
$ npm install connect
$ npm install serve-static
$ node server.js


But it doesnt work. In every "install" trying says that it doesn't find the package.json.

Configuration:

Windows: 10

NodeJS: 6.5.0



Thank you!

Answer

First create a package.json (here using the default values by including -y) and then install the dependencies while saving them into the package.json using -S.

$ npm init -y
$ npm install -g express-generator
$ npm install express -S
$ npm install connect -S
$ npm install serve-static -S
$ node server.js

Note that you can leave out the installation of express-generator as it should already be installed globally.

Documentation on npm init.

Comments