react-starter-kit icon indicating copy to clipboard operation
react-starter-kit copied to clipboard

missing script: deploy

Open seanli opened this issue 11 years ago • 7 comments

Typing "npm run deploy" gives missing script error. Deploy script is not in the tools folder. Is there an example on how to deploy the built bundle to Github pages? Thanks :)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

seanli avatar Aug 17 '15 00:08 seanli

Run npm install git-push --save-dev;

Create tools/deploy.js file with approximately the following content:

import push from 'git-push';

const remote = {
  name: 'production',
  url: 'http://github.com/user/test.example.com',
  branch: 'gh-pages'
};

export default async () => {
  await build();
  await new Promise(resolve => push('./build', remote, resolve));
});

Add this script to package.json/scripts. Then you can deploy your app with a single command:

$ npm run deploy

koistya avatar Aug 17 '15 01:08 koistya

Thanks @koistya ! I'll give that a try

seanli avatar Aug 18 '15 17:08 seanli

Hi, I tried this code in combination with your azure branch, but it doesn't seem to work. Azure Apps has a problem finding some modules:

Thu Aug 20 2015 09:34:06 GMT+0000 (Coordinated Universal Time): Unaught exception: Error: Cannot >find module 'source-map-support' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (D:\home\site\wwwroot\server.js:1:63) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

A year ago I tried to deploy a webapp using the MEAN stack to Azure Apps and I ran into a lot of problems... I hope there's just something missing here ; )

The script mentioned above works with a little change for git repositories in general.

import push from 'git-push';

const remote = {
  name: 'production',
  url: 'http://github.com/user/test.example.com',
  branch: 'gh-pages'
};

export default async () => {
  // await build();
  await require('./build')();
  await new Promise(resolve => push('./build', remote, resolve));
});

janhase avatar Aug 20 '15 11:08 janhase

@janhase it's seems like you can deploy to Azure as it is, without bringing the .deployment and deploy.cmd scripts from the azure branch (since azure creates these files for you if they don't exist). I'm wondering why it complains about the source-map-support module because in Azure it should run npm install --production command, which skips devDependencies (as it should be).

koistya avatar Aug 21 '15 00:08 koistya

@koistya I got it up and running on Azure and Heroku. I changed the scripts section of the package.json to:

"scripts": {
    ...
    "start-dev": "babel-node --eval \"require('./tools/start')().catch(err => console.log(err.stack))\"",
    "start": "NODE_ENV=production node server.js"
  }

Azure, Heroku & Co run "npm start", so there should be no dev stuff in there. Or at least a switch between production and dev.

EDIT: A better way could be to exchange

"start-dev": "babel-node --eval \"require('./tools/start')().catch(err => console.log(err.stack))\""

with

"start": "NODE_ENV=production node server.js"

in copy.js

janhase avatar Aug 24 '15 12:08 janhase

I know this is a very old thread but I'm running up against the same error when attempting to deploy the react-starter-kit to Azure.

Error: Cannot find module 'source-map-support'

I think @janhase's solution is out-of-date now. Has anyone ran into this error? How did you fix it?

Thanks in advanced!

mglace avatar Aug 07 '18 15:08 mglace

@seanli thank you very much for crating this issue! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

ulani avatar May 27 '21 19:05 ulani