Uncaught ReferenceError: process is not defined

前端 未结 3 2044
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 23:06

I am using node.js to create a web application. When I run the application (either by opening index.html on the browser or using the command \"npm start\" on the terminal) I

3条回答
  •  醉话见心
    2021-01-07 23:56

    Node.js code must be run by the node process, not the browser (the code must run in the server).

    To run the code, you must run the command:

    node server.js
    

    And then you can access your server from a browser by typing "http://localhost:8080", for example. You must have a file server.js (or whatever) with the server code you want (in this case, creating a web server in port 8080).

    You can follow this easy example, using express as http server module: http://expressjs.com/starter/hello-world.html

提交回复
热议问题