educative.io

Educative

How to use on my device without using educative platform

for running it without educative platform ,first i need to write command npm start after that what should i do to run live web server ?

Hello @Ashutosh_Kumar_Singh

npm start command by default will run node server.js if no start property is defined in the scripts portion of package.json file. You can add the start property in the scripts section and execute the command of your choice just like this:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
  }
}

Now if you will execute npm start, it will look for the file index.js in the root directory and execute that. After that you just have to follow the local host link in your browser to see the output. The link is usually http://localhost:3000/ or can be something else depending on your configurations.

Now coming to second part of your query. To run live web server, you can use live-server module of npm. You just have to install live server using npm install live-server and then simply execute live-server in the root of your directory. Now you can make changes to your files and see them in action in real-time instead of re-running your application again and again. You can find complete documentation here.

Alternative, Visual Studio Code also provides a live server extension which is also very easy to use.

Hope this helps!

1 Like