Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Last active March 27, 2024 20:30
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • 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

@abishekh07
Copy link

I am facing an issue with the npm live-server

`events.js:174
throw er; // Unhandled 'error' event
^

Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)`

Can anybody tell me how I can resolve this!??

@ozegovicka
Copy link

aaaaw it's not workiiing. whyyy? :@ :(

  • live-server@1.2.1
    added 55 packages from 42 contributors and audited 6017 packages in 13.349s
    found 0 vulnerabilities
    Desktop\24slides> live-server
    'live-server' is not recognized as an internal or external command,
    operable program or batch file.

Copy link

ghost commented Jul 4, 2019

Hi everyone. I'm new in this npm live-server. I'm having quite a problem, I tried to google it but no result. Well, every time I type live-server in my terminal, it shows me the LISTING DIRECTORY in the local host, instead of loading the website I created. I don't know what's the problem, I checked everything my teacher said, and it's all good except for that.

@dtrealm
Copy link

dtrealm commented Sep 5, 2019

I followed the instructions to install live-server but when I try to run it I get this error:

live-server .
/Users/mn/.npm-global/lib/node_modules/live-server/node_modules/opn/index.js:11
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/mn/.npm-global/lib/node_modules/live-server/index.js:11:9)
at Module._compile (module.js:570:32)
➜ public vi index.html

I am running on a Mac
I am stuck!

same question

@donmccurdy
Copy link
Author

@dtrealm @mnicknish If you're seeing an error about SyntaxError: Unexpected identifier, your version of Node.js is out of date. Running node -v will tell you what version it is. You can install a newer one at https://nodejs.org/en/, or use something like nvm if you need to have multiple versions installed at once.

@Abadeolu
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$

@rightouscoder
Copy link

hey guys just installed liveserver globally and it works...cos i have been having prob with the one i installed on vscode

@Hlanganani101
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

@Jesse-Bett
Copy link

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

@callmejetcar
Copy link

Is this something that can stage the edits for json templates and pages -- like from HubSpot specifically? I cannot find anything online saying yes or no, and it's only previewing file trees for me in the browser.

@welintonbg
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

@Nelsonssf
Copy link

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! 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/idueedit/.npm/_logs/2020-09-22T20_59_12_341Z-debug.log

Recebo essa mensagem de erro!

@fikriRif
Copy link

I followed the instructions to install live-server but when I try to run it I get this error:

live-server .
/Users/mn/.npm-global/lib/node_modules/live-server/node_modules/opn/index.js:11
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/mn/.npm-global/lib/node_modules/live-server/index.js:11:9)
at Module._compile (module.js:570:32)
➜ public vi index.html

I am running on a Mac
I am stuck!

Try to update nodeJs

@Zeesy
Copy link

Zeesy commented Nov 1, 2020

I've installed on MacOS 10.14.6 using
npm install -g live-server
and
sudo npm install -g live-server
running node v12.6.0.

live-server
results in
bash: live-server: command not found

I have previously added
export PATH=/Users/Zeesy/.npm-packages/bin
to .bash_profile, but am getting the same error message with or without it. Any recommendadtions on troubleshooting would be appreciated.

@13thRooney
Copy link

I've installed on MacOS 10.14.6 using
npm install -g live-server
and
sudo npm install -g live-server
running node v12.6.0.

live-server
results in
bash: live-server: command not found

I have previously added
export PATH=/Users/Zeesy/.npm-packages/bin
to .bash_profile, but am getting the same error message with or without it. Any recommendadtions on troubleshooting would be appreciated.

I get the same error on both bash and fish shells:

fish: Unknown command: live-server

@billbunkum
Copy link

billbunkum commented Feb 5, 2021

I am facing an issue with the npm live-server

`events.js:174
throw er; // Unhandled 'error' event
^

Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)`

Can anybody tell me how I can resolve this!??

Try using yarn instead of npm:
$ yarn add live-server@1.2.1
Of course, you must also have yarn installed. You can do this using brew or npm or a couple other ways (on Yarn's website):
$ npm install --global yarn

or

$ brew install yarn

@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