Node gets wrong HTML from package.json when executing npm start - node.js

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!

Related

Getting Error "can not GET/ " for trying to preview lite-server and using only command prompt in node.js

I am learning a course about bootstrap 4 in Coursera. I got some instructions to preview lite-server on the browser by command prompt but when I try to start the lite-server from the command prompt like - npm start it does show the message can not GET/ I tried to find a solution about it but all I got some codes as a solution like this
app.get('/api/courses', (req, res) => { ... }
)
But I don't think so I have a file like this. I am just working with cmd.this is my package.json:
{
"name": "git-test-1",
"version": "1.0.0",
"description": "This is a description ",
"main": "index-1.html",
"scripts": {
"start":"npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite":"lite-server"
},
"repository": {
"type": "git",
"url": "git+https://Sheikh_Araf#bitbucket.org/Sheikh_Araf/git-test.git"
},
"author": "Sheikh Araf",
"license": "ISC",
"homepage": "https://bitbucket.org/Sheikh_Araf/git-test#readme",
"devDependencies": {
"lite-server": "^2.5.4"
}
}

Why do I keep getting error trying to run npm scripts?

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"
}
}

Node process won't start with bot

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

framework7: npm ERR! missing script: serve on package.json

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"
}

http-server not stopping server when using Ctrl+C

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"

Resources