- Hands-On Full-Stack Web Development with GraphQL and React
- Sebastian Grebe
- 218字
- 2021-07-02 13:20:44
Running Express.js in development
To launch our server, we have to add a new script to our package.json.
We will add the following line to the scripts property of the package.json file:
"server": "nodemon --exec babel-node --watch src/server src/server/index.js"
As you can see, we are using a command called nodemon. We need to install it first:
npm install --save nodemon
Nodemon is an excellent tool for running a Node.js application. It can restart your server when the source changes.
For example, to get the above command working follow the steps below:
- Furthermore, we must install the @babel/node package, because we are transpiling the back end code with Babel, using the --exec babel-node option. It allows the use of the import statement:
npm install --save-dev @babel/node
Providing --watch as the option following a path or file will permanently track changes on that file or folder and reload the server to represent the latest state of your application. The last parameter refers to the actual file being the starting execution point for the back end.
- Start the server now:
npm run server
When you now go to your browser and enter http://localhost:8000, you will see the text Hello World! from our Express.js callback function.
Chapter 3, Connecting to the Database, covers how Express.js routing works in detail.
- 計(jì)算機(jī)網(wǎng)絡(luò)與通信(第2版)
- 網(wǎng)絡(luò)創(chuàng)新指數(shù)研究
- 中小型局域網(wǎng)組建、管理與維護(hù)實(shí)戰(zhàn)
- Wireshark網(wǎng)絡(luò)分析就這么簡(jiǎn)單
- 物聯(lián)網(wǎng)與無(wú)線傳感器網(wǎng)絡(luò)
- 網(wǎng)絡(luò)環(huán)境中基于用戶視角的信息質(zhì)量評(píng)價(jià)研究
- TD-LTE無(wú)線網(wǎng)絡(luò)規(guī)劃與設(shè)計(jì)
- 4G小基站系統(tǒng)原理、組網(wǎng)及應(yīng)用
- 端到端QoS網(wǎng)絡(luò)設(shè)計(jì)
- 深入理解Nginx:模塊開(kāi)發(fā)與架構(gòu)解析
- 一本書(shū)讀懂TCP/IP
- 物聯(lián)網(wǎng)基礎(chǔ)及應(yīng)用
- 精通SEO:100%網(wǎng)站流量提升密碼
- 深入理解計(jì)算機(jī)網(wǎng)絡(luò)
- 黑客與反黑工具使用詳解