简体   繁体   中英

How to use multiple node.js files

I am having trouble having my VS17 Node.js project use multiple node.js files to generate webpages. The have the standard http.createServer, but only one will generate. When I change the url to another Node file, it says it can't load that localhost.

Can any of you help? Does it have anything to do with package.json?

If you're new to node, you should consider using a framework like expressjs. It will abstract away a lot of the hard stuff so you can focus more on just making a website, and not reinventing the wheel.

https://expressjs.com/

There is a generator utility that will scaffold your project for you.

https://expressjs.com/en/starter/generator.html

Install the generator

npm install express-generator -g

Run the generator

express ./myapp/

Then you will have a fully functional server that you can run with npm start

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