How to initialize a nodejs project

To initialize a nodejs project:

  1. run npm init, filled info, we will get a package.json file.
  2. install some npm dependencied to make this nodejs server work, for example:
    • npm install express cors axios
      express is a HTTP framework for running node servers.
      cors make us be able to call this server from anywhere else on the internet.
      axios make us be able to make API calls to chat engine.io
    • npm install --save-dev nodemon
      to make nodemon run our node server, modify scripts in package.json file and add an attribute start : "start": "nodemon index.js"
  3. write index.js file

你可能感兴趣的:(javascript)