I am using Visual Studio Code to follow the HTML fundamentals lessons of Flatiron Bootcamp.
In order to get a running local web server to see my code in action I chose to use the following procedure which is valid for MAC or PC and I saw in this website: Visual Studio Code and local web server.
- Create folder for your project and add an index.html file and a package.json file to it. Inside package.json file copy/paste the following text:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "name": "Demo", "version": "1.0.0", "description": "demo project.", "scripts": { "lite": "lite-server --port 10001", "start": "npm run lite" }, "author": "", "license": "ISC", "devDependencies": { "lite-server": "^1.3.1" } } |
I tried that but it didn’t work, I was getting an error (to see more about it check this link) :
String does not match the pattern of "^(?:@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$".
So I changed the string ‘Demo’ to ‘demo’ and all good.
- Install Node.js and npm. I follow this website: Installing Node.js and NPM on Mac.
- First, install Homebrew running on your terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
- Get the latest version of Node running:
brew update
-
- Install node running:
brew install node
-
- Test that you got Node running:
node -v
-
- Test that you got NPM running:
npm -v
- Install the web server running:
npm install
This will install lite-server (defined in package.json), a static server that loads index.html in your default browser and auto refreshes it when application files change.
- Start the local web server running:
npm start
Done!!