I am using a simple npm module http-server https://www.npmjs.com/package/http-server to server static website.
This is my package json
{
"name": "dashboard-ng-starfleet",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"./node_modules/http-server/bin/http-server -p=8080"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"homepage": "",
"devDependencies": {
"http-server": "^0.10.0"
}
}
Server starts once but once i stop it using Ctrl+C in terminal and again start server, it says Address already in use.
Ideally it should have stopped.
Any help ?
Your start script should be
"start":"./node_modules/http-server/bin/http-server -p 8080"
Related
I have a package.json file that looks like:
{
"name": "assignment-1",
"version": "1.0.0",
"description": "This is the Git and Node basic learning project",
"main": "aboutus.html",
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://path_to_git/first-assignment.git"
},
"author": "",
"license": "ISC",
"homepage": "https://path_to_git/first-assignment#readme",
"devDependencies": {
"lite-server": "^2.2.2"
},
"bugs": {
"url": "https://path_to_git/first-assignment/issues"
},
but when I execute npm start, instead of aboutus.html, the index.html webpage opens.
Any idea what I am doing wrong and I don't get the aboutus.html loading as I want it to?
I think I've found the solution:
The index.html appears as the default page, in localhost:3000. Then I simply need to write localhost:3000/aboutus.html to get to the page I wanted to go... Seems like it was pretty simple after all!
I am just getting to learn node and webpack. I was following a tutorial, but I keep running into an error. Details of the error and my setup is given below:
error details
log file
My setup
package.json content
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"path": "^0.12.7"
}
}
I am trying to deploy a bot to run on Heroku servers. It fails to compile the app when I try to commit. Here is my package.json
{
"name": "Bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node bot.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.0.2",
"dotenv": "^8.2.0"
}
}
bot.js is the correct name for the bot configuration file. It works fine when I take out start: node bot.js but the bot doesn't come online of course.
Try Changing main to bot.js.
https://devcenter.heroku.com/articles/deploying-nodejs
I am trying to run my node server as a background process using forever. When I close the putty terminal the server still shuts down. What am I doing worng?
command: forever -c "npm start &" ./
package.json
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon ./bin/www",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
.....
}
}
I added serve keyword inside package.json with localhost:8080 as it's value but it wont work. I tried using localhost ip address instead of "localhost" still got error.
On my package.json
{
"name": "package-lock",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"framework7": "^3.0.1"
},
"devDependencies": {},
"scripts": {
"serve":"localhost:8080",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}