How to initialize a nodejs project

2024-01-07 17:23:38

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

文章来源:https://blog.csdn.net/weixin_43561635/article/details/135425521
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。