javascript - nodejs bootstrap project works local only -


ive been trying out different things, , looking various ways solve it, i'm in need of hints make work.

i have working nodejs bootstrap project gulp. website functions locally.

so in project have fiollowing files (among other folders) :

  • gulpfile.js
  • index.html
  • package.json

when locally run project via 'gulp dev' seems perfect. on heroku after deploying gives me error: npm err! missing script: start

this makes sense, because indeed package.json doesn't have start script. how can work on local?

any leads? thanks

node.js file

name index.js

first before start move current files new folder called public in parent folder above public create file index.js

once in parent folder above public run in command line directory created index.js file

npm express --save

this install mini framework node.js , save project.json config

for index.js file content

/// start var express = require('express'); var path = require('path') var app = express();         var port = process.env.port || 80;  // allows files visible without having type in // index.html url / , you'll url app.use(express.static(path.join(__dirname, 'public'),{   extensions: ['html']} ));  app.listen(port); ///end 

you need make sure index.js (node file) in 1 folder above rest of project. project should in folder called public in case

before upload heroku working on local machine

you need run node index.js if errors can work through them generic static serving node.js server.

last thing need go project.json file , add following can add right above "title" in case it's easy find later

"scripts": {   "start": "node index.js" } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -