How to configure index.js with hapi npm for deployment
I received this project to deploy, which uses the hapi npm that I am not familiar with. I am able to run it successfully localy but when I try to deploy it I get an error, on heroku
the error is:
npm ERR! missing script: start
I think maybe I have to change something in the index.js maybe the port or the host inside server const?
Here is my index.js
const Hapi = require('hapi');
const path = require('path');
const fs = require('fs');
const util = require('util');
const readDir = util.promisify(fs.readdir);
const server = Hapi.server({
port: 3000,
host: 'localhost',
routes: {
files: {
relativeTo: path.join(__dirname, 'public')
}
}
})
const start = async () => {
await server.register(require('vision'));
await server.register(require('inert'));
server.views({
engines: {
html: require('handlebars')
},
relativeTo: __dirname,
path: 'templates',
layout: 'layout-other',
layoutPath: 'templates/layout'
});
// Static files
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: path.join(__dirname, 'public'),
listing: true
}
}
});
require('./routes')(server);
server.start();
}
start();
Thanks
node.js heroku web-deployment package.json
add a comment |
I received this project to deploy, which uses the hapi npm that I am not familiar with. I am able to run it successfully localy but when I try to deploy it I get an error, on heroku
the error is:
npm ERR! missing script: start
I think maybe I have to change something in the index.js maybe the port or the host inside server const?
Here is my index.js
const Hapi = require('hapi');
const path = require('path');
const fs = require('fs');
const util = require('util');
const readDir = util.promisify(fs.readdir);
const server = Hapi.server({
port: 3000,
host: 'localhost',
routes: {
files: {
relativeTo: path.join(__dirname, 'public')
}
}
})
const start = async () => {
await server.register(require('vision'));
await server.register(require('inert'));
server.views({
engines: {
html: require('handlebars')
},
relativeTo: __dirname,
path: 'templates',
layout: 'layout-other',
layoutPath: 'templates/layout'
});
// Static files
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: path.join(__dirname, 'public'),
listing: true
}
}
});
require('./routes')(server);
server.start();
}
start();
Thanks
node.js heroku web-deployment package.json
add a comment |
I received this project to deploy, which uses the hapi npm that I am not familiar with. I am able to run it successfully localy but when I try to deploy it I get an error, on heroku
the error is:
npm ERR! missing script: start
I think maybe I have to change something in the index.js maybe the port or the host inside server const?
Here is my index.js
const Hapi = require('hapi');
const path = require('path');
const fs = require('fs');
const util = require('util');
const readDir = util.promisify(fs.readdir);
const server = Hapi.server({
port: 3000,
host: 'localhost',
routes: {
files: {
relativeTo: path.join(__dirname, 'public')
}
}
})
const start = async () => {
await server.register(require('vision'));
await server.register(require('inert'));
server.views({
engines: {
html: require('handlebars')
},
relativeTo: __dirname,
path: 'templates',
layout: 'layout-other',
layoutPath: 'templates/layout'
});
// Static files
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: path.join(__dirname, 'public'),
listing: true
}
}
});
require('./routes')(server);
server.start();
}
start();
Thanks
node.js heroku web-deployment package.json
I received this project to deploy, which uses the hapi npm that I am not familiar with. I am able to run it successfully localy but when I try to deploy it I get an error, on heroku
the error is:
npm ERR! missing script: start
I think maybe I have to change something in the index.js maybe the port or the host inside server const?
Here is my index.js
const Hapi = require('hapi');
const path = require('path');
const fs = require('fs');
const util = require('util');
const readDir = util.promisify(fs.readdir);
const server = Hapi.server({
port: 3000,
host: 'localhost',
routes: {
files: {
relativeTo: path.join(__dirname, 'public')
}
}
})
const start = async () => {
await server.register(require('vision'));
await server.register(require('inert'));
server.views({
engines: {
html: require('handlebars')
},
relativeTo: __dirname,
path: 'templates',
layout: 'layout-other',
layoutPath: 'templates/layout'
});
// Static files
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: path.join(__dirname, 'public'),
listing: true
}
}
});
require('./routes')(server);
server.start();
}
start();
Thanks
node.js heroku web-deployment package.json
node.js heroku web-deployment package.json
edited Nov 28 '18 at 12:23
ArunPratap
2,1312928
2,1312928
asked Nov 28 '18 at 10:29
Jack Jack
959
959
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
missing script: start
. In your package.json,
means you are missing to configure where to start
check your package.json
file you should define that like this
"scripts": {
"start": "node index.js"
}
If your app has a build step that you’d like to run when you deploy, you can use a Postinstall script in
package.json:
add a comment |
npm start
is a script that is created in your package.json
file.
You can check more about it here
An example of a package.json
file:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js",
"somescript":"do something"
},
"dependencies": {
"express": "^4.13.3"
},
"license": "MIT"
}
npm start
will run the "start" script. Which means it will run node index.js
npm somescript
will run the "somescript" script. Which means it will run do something
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517306%2fhow-to-configure-index-js-with-hapi-npm-for-deployment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
missing script: start
. In your package.json,
means you are missing to configure where to start
check your package.json
file you should define that like this
"scripts": {
"start": "node index.js"
}
If your app has a build step that you’d like to run when you deploy, you can use a Postinstall script in
package.json:
add a comment |
missing script: start
. In your package.json,
means you are missing to configure where to start
check your package.json
file you should define that like this
"scripts": {
"start": "node index.js"
}
If your app has a build step that you’d like to run when you deploy, you can use a Postinstall script in
package.json:
add a comment |
missing script: start
. In your package.json,
means you are missing to configure where to start
check your package.json
file you should define that like this
"scripts": {
"start": "node index.js"
}
If your app has a build step that you’d like to run when you deploy, you can use a Postinstall script in
package.json:
missing script: start
. In your package.json,
means you are missing to configure where to start
check your package.json
file you should define that like this
"scripts": {
"start": "node index.js"
}
If your app has a build step that you’d like to run when you deploy, you can use a Postinstall script in
package.json:
edited Dec 19 '18 at 9:39
answered Nov 28 '18 at 10:39
ArunPratapArunPratap
2,1312928
2,1312928
add a comment |
add a comment |
npm start
is a script that is created in your package.json
file.
You can check more about it here
An example of a package.json
file:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js",
"somescript":"do something"
},
"dependencies": {
"express": "^4.13.3"
},
"license": "MIT"
}
npm start
will run the "start" script. Which means it will run node index.js
npm somescript
will run the "somescript" script. Which means it will run do something
add a comment |
npm start
is a script that is created in your package.json
file.
You can check more about it here
An example of a package.json
file:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js",
"somescript":"do something"
},
"dependencies": {
"express": "^4.13.3"
},
"license": "MIT"
}
npm start
will run the "start" script. Which means it will run node index.js
npm somescript
will run the "somescript" script. Which means it will run do something
add a comment |
npm start
is a script that is created in your package.json
file.
You can check more about it here
An example of a package.json
file:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js",
"somescript":"do something"
},
"dependencies": {
"express": "^4.13.3"
},
"license": "MIT"
}
npm start
will run the "start" script. Which means it will run node index.js
npm somescript
will run the "somescript" script. Which means it will run do something
npm start
is a script that is created in your package.json
file.
You can check more about it here
An example of a package.json
file:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js",
"somescript":"do something"
},
"dependencies": {
"express": "^4.13.3"
},
"license": "MIT"
}
npm start
will run the "start" script. Which means it will run node index.js
npm somescript
will run the "somescript" script. Which means it will run do something
answered Nov 28 '18 at 10:42
Aritra ChakrabortyAritra Chakraborty
2,43811015
2,43811015
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517306%2fhow-to-configure-index-js-with-hapi-npm-for-deployment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown