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

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

Related

What is the idiomatic way to run a Node.js project

what is the idiomatic way to run a Node.js project that has package.json with '"main": "index.js"' inside? do I run something like "node run" or "npm run" ?
The package.json file:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
And index.js file exists. So what is the idiomatic way?
You can add a start script to your package.json:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
This way, you can start your project by just running npm start.

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

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"

http-server npm module serving wrong files by default

i am using http-server https://www.npmjs.com/package/http-server
I am using src folder as the path.
But the server is starting directly at Project folder listing the directories.
How can i server src folder.
My folder structure is
Project
package.json
src
index.html
And 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": "http-server ./src -o -p 9000"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"homepage": "",
"devDependencies": {
"http-server": "^0.10.0"
}
}

Resources