nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.9k stars 7.55k forks source link

[Bug]: Nest fails on AWS/EBS #817

Closed iamclaytonray closed 6 years ago

iamclaytonray commented 6 years ago

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When trying to deploy a Nest server to Elastic Beanstalk, I get an error returned that I put in a code block below. I've tried different TypeScript configurations, different regions, and a whole bunch of other things. Nothing has worked and the error message hasn't changed.

Expected behavior

Ideally, I should be able to ship to prod with no issues from Nest itself. Any issues I have should come from any bugs I write.

Minimal reproduction of the problem with instructions

Here is a repo that you can use

Assuming you have the AWS/EBS CLI installed, here are some instructions:

  1. eb init (Select options manually)
  2. eb create (Select options manually)

Here is the error from running eb logs:

/var/app/current/node_modules/@nestjs/core/nest-factory.js:21
    async create(module, serverOrOptions, options) {
          ^^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/app/current/node_modules/@nestjs/core/index.js:16:22)

What is the motivation / use case for changing the behavior?

To be able to ship to prod with no issues.

Environment


Nest version: 5.0.0

 I have run it against latest as well.

For Tooling issues:
- Node version: XX  
6.14.3
- Platform:  
Linux 4.14.47-56.37.amzn1.x86_64            
iamclaytonray commented 6 years ago

To keep the original issue cleaner, I added the environment from the EC2 instance, not my local machine. Everything works fine on my machine. It's just in production that it fails

kamilmysliwiec commented 6 years ago
We follow the Node.js release schedule which recently moved to 8.x as an active LTS version. Therefore, Nest 5 supports >= 8.9.0 as the lowest version now. This shift gave us sustainable performance boosts thanks to the es2017 target of the TypeScript compilation.

https://docs.nestjs.com/migration-guide

iamclaytonray commented 6 years ago

Sorry for not responding to this. I see that now. Maybe you can make this a little more prominent and let users know that if they want to run the latest version of Nest in prod, they need to use containers (docker, etc) or another option?

kamilmysliwiec commented 6 years ago

As far as I know, EBS supports Node.js 8.x

lawrencetaur commented 6 years ago

I managed to get it to work after a lot of trial and error using the https://github.com/nestjs/typescript-starter.

In main.ts file, change line 6 await app.listen(3000); to await app.listen(process.env.PORT || 8000);

I used ebs cli instead of uploading a zip, this is the key.

For configuration, like @kamilmysliwiec use Node 8+, I used 8.11.3, the latest they have. The default node command needs to be overridden with npm run start:prod

screen shot 2018-06-30 at 8 29 03 pm

iamclaytonray commented 6 years ago

I was unaware of changing the node version. Where is that specifically? The only place I saw to change Node had the highest version being at 6.x.x

iamclaytonray commented 6 years ago

I have everything else set for prod. Database URIs, ports, etc

lawrencetaur commented 6 years ago

screen shot 2018-06-30 at 8 58 12 pm

Click modify under the Software box

iamclaytonray commented 6 years ago

Thanks!

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.