i have used Xampp and JetBrain WebStorm to run an AngularJS project. But it\'s complicated and low performance.Is there any other way to run an AngularJS project?
Assuming you already have node.js installed, you can use browser sync for synchronized browser testing.
"Assuming that you have nodejs installed",
mini-http is a pretty easy command-line tool to create http server,
install the package globally npm install mini-http -g
then using your cmd (terminal) run mini-http -p=3000
in your project directory
And boom! you created a server on port 3000 now go check http://localhost:3000
Note: specifying a port is not required you can simply run mini-http
or mh
to start the server
I use:
Install Node.js. and npm. npm is installed with Node.js
Placed inside the root project directory
$ cd <your_angularjs_project>
The next command creates package.json
$ npm init
Install express ==> Fast, unopinionated, minimalist for node:
$ npm install express --save
Install morgan ==> HTTP request logger middleware for node.js
$ npm install morgan --save
create file server.js
add the following code in server.js file
// Required Modules
var express = require("express");
var morgan = require("morgan");
var app = express();
var port = process.env.PORT || 3002;
app.use(morgan("dev"));
app.use(express.static("./"));
app.get("/", function(req, res) {
res.sendFile("./index.html"); //index.html file of your angularjs application
});
// Start Server
app.listen(port, function () {
console.log( "Express server listening on port " + port);
});
Finally run your AngularJS project in localhost server:
$ node server.js
An angular application can be deployed using any Web server on localhost. The options below outline the deployment instructions for several possible webserver deployments depending on your deployment requirements.
Windows IIS must be enabled
1.1. In Windows, access the Control Panel and click Add or Remove Programs.
1.2. In the Add or Remove Programs window, click Add/Remove Windows Components.
1.3. Select the Internet Information Services (IIS) check box, click Next, then click Finish.
1.4. Copy and extract the Angular Application Zip file to the webserver root directory: C:\inetpub\wwwroot
Use local-web-server npm package.
https://www.npmjs.com/package/local-web-server
$ npm install -g local-web-server
$ cd <your-app-folder>
$ ws
Also, you can run
$ ws -p 8181
-p defines the port you want to use
After that, just go to your browser and access http:localhost:8181/
You can also setup the environment in visual studio code. Run Ctrl + Shift + P, Then type ctr in the box that appears and select tasks:Configure Task Runner, Then change the task.json file to this: { "version": "0.1.0", "command": "explorer", "windows": { "command": "explorer.exe" }, "args": ["index.html"] }
, save your changes, Then select your index.html file and type Ctrl + Shift + B. This will open the project with your default browser.