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

SyntaxError: Invalid left-hand side in assignment #846

Open
pbassut opened this issue Dec 12, 2020 · 5 comments
Open

SyntaxError: Invalid left-hand side in assignment #846

pbassut opened this issue Dec 12, 2020 · 5 comments

Comments

@pbassut
Copy link

pbassut commented Dec 12, 2020

Describe the bug

Looks like the tool doesn't play nice when you have an .env variable in the same folder you run serverless. I understand there's a way of passing environment variables to the script but for people coming in trying to deploy their existing apps that already use this form of passing parameters might have a bad experience with the tool.

Actual behavior

It crashes with:

SyntaxError: Invalid left-hand side in assignment
    at wrapSafe (internal/modules/cjs/loader.js:1116:16)
    at Module._compile (internal/modules/cjs/loader.js:1164:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at hasCustomGetInitialProps (/Users/.../next/dist/build/utils.js:24:1064)
    at build (/Users/...node_modules/next/dist/build/index.js:15:2605)
Loaded env from /Users/.../.env
info  - Creating an optimized production build...
info  - Using external babel configuration from /Users/.../babel.config.js
info  - Collecting page data...

Expected behavior

I would like for it to read my .env file. But if that's not possible, don't crash on me.

Steps to reproduce

Just have a .env in your folder and run serverless

Versions

  • OS/Environment: OSX
  • @sls-next/serverless-component version: 1.19.0-alpha.21
  • Next.js version: Next.js v9.5.5
@raslasarslas
Copy link

I have the same error, does anyone know how to solve it?

@pbassut
Copy link
Author

pbassut commented Apr 25, 2021

Since the error is because of an environment file in the same folder you run (serverless delpoy), as a workaround, I found another way of setting my environment variables. Be creative in your setup and find your own.

@erodrig
Copy link

erodrig commented May 23, 2021

so one year and still nothing, strong community

@dphang
Copy link
Collaborator

dphang commented May 25, 2021

Sorry it was missed, unfortunately I'm the only active maintainer right now (always looking for more!) and maintaining in my free time so I might miss some issues.

I could not repro the issue myself from steps above. @pbassut Do you have a minimal repro repo you can share? from the original stacktrace I couldn't see it erroring out in any code in this component (failure seems to originate from next/dist/build/index.js?)

@javiermanzano
Copy link

javiermanzano commented Aug 24, 2022

This issue saved me A LOT of time.

Thanks @pbassut . I finally created a script to rename and recreate .env file on every deploy

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

5 participants