Reactgo: Deploy to AWS

Created on 28 Oct 2016  ·  12Comments  ·  Source: reactGo/reactGo

Description

  • Type: Question

Question

When I`m trying to start my project using the npm start command at AWS Ubuntu server I'm getting the error:

> cross-env NODE_ENV=production node compiled/index.js

module.js:327
    throw err;
    ^

Error: Cannot find module '/home/ubuntu/compiled/index.js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:974:3

What I did wrong?

Thanks for your help.

Documentaion

Most helpful comment

So far, looking good!!
Just some of my thoughts

  • Like for the IAM role!!
  • I usually install NVM on the instance first. This lets me install and change node version if i need for some reason (Its possible to install it globally in case you have several users on the insnatce)
  • Regarding the security group - mind the ports that you open 😝 you dont want outside people to access the mongodb port. Also for the port 3000, If you're using nginx or something then it redirects your request from port 80 to 3000 anyway

All 12 comments

hi @mnoleto, I'm not sure what the root cause of your issue is, did you follow the deployment instructions for AWS that I wrote ? They are a few months old, but they should still be up to date.

Hi @caranicas
Thank for your reply.
The only thing that I made different was the "Upload your file" part. I sent the files to the server using Git instead of scp. Now I`m following exactly your instructions. I hope that will be sufficient.

@mnoleto any luck?

@caranicas no, I recreated the instance from scratch following the instructions and I still can`t run the npm start ou npm run build.

The error when I try the npm run build:

Error: spawn webpack ENOENT
    at exports._errnoException (util.js:907:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
    at Function.Module.runMain (module.js:443:11)
    at startup (node.js:139:18)
    at node.js:974:3

I think the information in the guide could be extended a bit :)
The way we work on our team is:

  1. Running npm pack. This would pack all the project files (ignoring those that are in .gitignore file into a tar.gz file.
  2. We then copy this file to the AWS instance and open it using tar -xf XXXXXXXX.
  3. We switch to the newly created folder and run npm install followed by npm build.
    This process is done because some packages are environment dependent (compiled differently on mac and ubuntu) therefore they need to be installed on the instance itself.
  4. After running those commands its possible to start the server using npm start or using forever / pm2 to run the application indefinitely.
  5. Its always possible to create a script that runs all those commands for you (both on your computer and remotely on the instance)

Thank you very much. After a lot of tries I could make it work.

I had to update npm to v3 to install dependencies and run npm build:node in
separate. I don`t know why, but the npm build was not running or taking too
long.

The step by step you sent in the end was very helpful. I think you should
extend the docs :)

Best Regards.

2016-10-29 9:20 GMT-02:00 slavab89 [email protected]:

I think the information in the guide could be extended a bit :)
The way we work on our team is:

  1. Running npm pack. This would pack all the project files (ignoring
    those that are in .gitignore file into a tar.gz file.
  2. We then copy this file to the AWS instance and open it using tar -xf
    XXXXXXXX.
  3. We switch to the newly created folder and run npm install followed by npm
    build.
    This process is done because some packages are environment dependent
    (compiled differently on mac and ubuntu) therefore they need to be
    installed on the instance itself.
  4. After running those commands its possible to start the server using npm
    start or using forever / pm2 to run the application indefinitely.
  5. Its always possible to create a script that runs all those commands
    for you (both on your computer and remotely on the instance)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/reactGo/reactGo/issues/637#issuecomment-257086016,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACKpNnKBI7zQhnB99pIbtPUtZsOYsTuks5q4ywNgaJpZM4Kjdf_
.

I'll add to the docs by @caranicas when I get the chance.

I'll be doing this with ~ 0 knowledge of AWS! Haha! Exciting times ahead!

I'm actually thinking of trying out AWS Linux instead of Ubuntu. I'll give that a go, but we'll see how it goes. Perhaps I will have to split this current doc into a separate doc https://github.com/reactGo/reactGo/blob/aws-docs-improvement/docs/deployment/aws.md

Would be good to get some 👀 on the working branch so far. But I will definitely split out my spike of trying the AWS Linux AMI for now.

Update: I've moved that aws doc changes to it's own file because I didn't want to make too many changes to the original aws.md. Also switched to using a branch on my own fork rather than using a branch in the upstream repository!

https://github.com/choonkending/reactGo/blob/aws-docs/docs/deployment/aws/linux-ec2.md

So far, looking good!!
Just some of my thoughts

  • Like for the IAM role!!
  • I usually install NVM on the instance first. This lets me install and change node version if i need for some reason (Its possible to install it globally in case you have several users on the insnatce)
  • Regarding the security group - mind the ports that you open 😝 you dont want outside people to access the mongodb port. Also for the port 3000, If you're using nginx or something then it redirects your request from port 80 to 3000 anyway

Closing as documentation was added regarding this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cleanshooter picture Cleanshooter  ·  7Comments

choonkending picture choonkending  ·  8Comments

kenjim83 picture kenjim83  ·  8Comments

azamatsmith picture azamatsmith  ·  6Comments

choonkending picture choonkending  ·  4Comments