Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue creating zip file on MacOS causes "Cannot find module '/var/task/app.js'" #803

Closed
codebravotech opened this issue Mar 5, 2020 · 4 comments

Comments

@codebravotech
Copy link

Prerequisites

  • [YES ] I am running the latest version. (up upgrade)
  • [ YES] I searched to see if the issue already exists.
  • [YES ] I inspected the verbose debug output with the -v, --verbose flag.
  • [YES ] Are you an Up Pro subscriber?

Description

I'm an Apex Up Pro user, trying to deploy an express server as lambdas. The deployment succeeds but then the lambda errors out with the following stack trace: 

 Mar 4th 09:23:04pm INFO staging 8bd9870 starting app: PORT=42273 command=node app.js
 Mar 4th 09:23:04pm INFO staging 8bd9870 started app
 Mar 4th 09:23:04pm INFO staging 8bd9870 waiting for app to listen on PORT
 Mar 4th 09:23:04pm ERRO staging 8bd9870 internal/modules/cjs/loader.js:638
 Mar 4th 09:23:04pm ERRO staging 8bd9870 throw err;
 Mar 4th 09:23:04pm ERRO staging 8bd9870 ^
 Mar 4th 09:23:04pm ERRO staging 8bd9870 
 Mar 4th 09:23:04pm ERRO staging 8bd9870 Error: Cannot find module '/var/task/app.js'
 Mar 4th 09:23:04pm ERRO staging 8bd9870 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
 Mar 4th 09:23:04pm ERRO staging 8bd9870 at Function.Module._load (internal/modules/cjs/loader.js:562:25)
 Mar 4th 09:23:04pm ERRO staging 8bd9870 at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
 Mar 4th 09:23:04pm ERRO staging 8bd9870 at startup (internal/bootstrap/node.js:283:19)
 Mar 4th 09:23:04pm ERRO staging 8bd9870 at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
 Mar 4th 09:23:19pm FATA staging 8bd9870 error creating handler: waiting for http://127.0.0.1:42273 to be in listening state: timed out after 15s: name=example-api type=server

I'm on Mohave 10.14.6 and it seems that Up is not correctly creating the zip file in lambda's accepted format. Any ideas what I can do here? This is a blocking issue for the project I have in flight, so any help would be super appreciated! 

Steps to Reproduce

Create simple express server with a health check endpoint. Run up deploy on MacOS and then try to hit that server.

@tj
Copy link
Member

tj commented Mar 5, 2020

Got your email! Just replying here in case anyone searches and comes across the same issue.

If you run up with up -v for verbose logs, you might be able to see if it's excluding an important file from the zip due to gitignore/upignore. If it doesn't seem like that's the problem let me know.

@codebravotech
Copy link
Author

No luck, everything seems to be there that I'm expecting! To reduce dependencies, I actually stripped down to a super simple example that just has a health check endpoint which returns a 200. And I get the same exact error...

@codebravotech
Copy link
Author

UPDATE: IATA (I am the asshole 🤣)

In package.json I have:

"main": "index.js",
  "scripts": {
    "start:development": "nodemon -L",
    "start:staging": "node .",
    "start:production": "node ."
...

So since Up looks for either "app.js" OR a script named simply "start" in package.json, my function had no valid entrypoint...

1 similar comment
@codebravotech
Copy link
Author

UPDATE: IATA (I am the asshole 🤣)

In package.json I have:

"main": "index.js",
  "scripts": {
    "start:development": "nodemon -L",
    "start:staging": "node .",
    "start:production": "node ."
...

So since Up looks for either "app.js" OR a script named simply "start" in package.json, my function had no valid entrypoint...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants