简体   繁体   中英

where is the server.js file on node

I'm reading a book about integrating nodejs with backbonejs and there is this part of the book (its supposed to be the basics)

(...)

npm install express

Finally, just copy the following code into server.js. As you can see from the code, it provides some simple endpoints served from localhost:8080/ books.

/**
* A simple API hosted under 127.0.0.1:8080/books
*/
var express = require('express');
var app = express();
varbookId = 100;

functionfindBook(id){
for(vari =0; i<books.length; i++){
if(books[i].id === id){
return books[i];
}
}
return null;

}

(...)

I already installed node and expressjs, where is that server.js file or where did I put it?

您需要自己创建该文件并将其放置在项目的根文件夹中

From the express.js documentation :

Now to create the application itself! Create a file named app.js or server.js , whichever you prefer, require express and then create a new application with express():

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM