Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Last active March 27, 2024 20:30
Show Gist options
  • Save donmccurdy/20fb112949324c92c5e8 to your computer and use it in GitHub Desktop.
Save donmccurdy/20fb112949324c92c5e8 to your computer and use it in GitHub Desktop.
Installing Node.js live-server

Installing Node.js live-server

The NodeJS live-server package runs a temporary server displaying any HTML/CSS/JS resources in the current folder. It automatically reloads the page in your browser when any of these files change.

OS X

  • Verify that Node.js is installed. If you see anything when you run which npm in a terminal, it is. If not, follow the instructions at nodejs.org to install.
  • Install live-server: npm install -g live-server
  • Move your terminal to where your pages live: cd <path-to-content>
  • Start the server: live-server .
  • Open localhost:8080 in a browser.

Windows

Linux

@TanmayMokal
Copy link

C:\Users\HP\Desktop\Natours project>live-server index.html
Serving "index.html" at http://127.0.0.1:8080
events.js:292
throw er; // Unhandled 'error' event
^

Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/c', 'start', '""', '/b', 'http://127.0.0.1:8080' ]
}
Screenshot (125)
I am totally fed up of this problem. I am also not able to use live-server extension also so please reply me if you have any solution...

@yandeu
Copy link

yandeu commented Apr 3, 2021

@TanmayMokal,
Check Five Server instead!

@anastasiyadem
Copy link

sudo npm install -g live-server

Thank you so much! It has helped :)

@Abdul300634
Copy link

Hey @peter543210, maybe you didn't install it globally with the -g flag?

Try to run the command: npm install -g live-server

Then live-server should be ready to be used.

i install live server using command
npm install -g live-server.
but error show on the screen
The term 'live-server' is not recognized as the name of a cmdlet, function, script file, or
operable program.

@Abdul300634
Copy link

Manual way
git clone https://github.com/tapio/live-server

cd live-server

npm install # Local dependencies if you want to hack

npm install -g # Install globally

i install live server using command
npm install -g live-server.
but error show on the screen
The term 'live-server' is not recognized as the name of a cmdlet, function, script file, or
operable program.

@Abdul300634
Copy link

error for git
how to solve this on windows

@sunsisuresh
Copy link

i keep getting this error, i am stuck, plese help.
Abrahams-MacBook-Pro:~ adeolu$ cd live-server
Abrahams-MacBook-Pro:live-server adeolu$ npm install -g # Install globally
npm WARN deprecated opn@6.0.0: The package has been renamed to open
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/adeolu/.npm/_logs/2019-10-17T08_21_53_026Z-debug.log
Abrahams-MacBook-Pro:live-server adeolu$

I also have this problem

I also have this problem and i solve it using this command

sudo npm install -g live-server

I used it but I got the message "command not found".I'm using Windows OS. I'm stuck Please help me

@MaheshReddyHR
Copy link

npm install -g live-server worked fine with me too

I did like npm install -g live-server
But I am getting error like command not found.will u please help me.

@donmccurdy
Copy link
Author

Hi all — please note that I'm not involved with live-server and can't provide help or support for using it. This is just a quick reference that assumes node.js is (1) properly installed and (2) on the $PATH. For help with live-server specifically or global installs with npm generally it may be better to ask on Stack Overflow.

@01alex01
Copy link

01alex01 commented Jan 6, 2023

I did like npm install -g live-server but this is what is showing below

sudo : The term 'sudo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1

  • sudo npm install -g live-server
  •   + CategoryInfo          : ObjectNotFound: (sudo:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

@Abbakarbeety
Copy link

try to run this code "sudo npm install live-server

@OPESCO8891
Copy link

How can I install react with npm, I tried using npm install -g create-react-app but it throws back an error

@billbunkum
Copy link

billbunkum commented Mar 27, 2024 via email

@billbunkum
Copy link

billbunkum commented Mar 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment