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

🐛 BUG: SyntaxError, missing ) after argument list #450

Closed
isaac-mcfadyen opened this issue Feb 12, 2022 · 7 comments
Closed

🐛 BUG: SyntaxError, missing ) after argument list #450

isaac-mcfadyen opened this issue Feb 12, 2022 · 7 comments

Comments

@isaac-mcfadyen
Copy link
Contributor

isaac-mcfadyen commented Feb 12, 2022

What version of Wrangler are you using?

0.0.0-bce731a

What operating system are you using?

MacOS

Describe the Bug

When running the command:
node -r dotenv/config node_modules/.bin/wrangler pages dev ./.svelte-kit/cloudflare (adapted from #190 (comment) for environment variables), Wrangler2 throws a SyntaxError: missing ) after argument list error (line 2).

The ./.svelte-kit/cloudflare directory contains a _worker.js and everything works fine if ommiting the node -r part.

@petebacondarwin
Copy link
Contributor

What is in dotenv/config? Perhaps there is a syntax error in there?

@isaac-mcfadyen
Copy link
Contributor Author

Sorry, forgot to provide the whole trace:

/Users/isaac/Projects/Node/example/node_modules/.bin/wrangler:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list

@petebacondarwin
Copy link
Contributor

Ah right! So the file node_modules/.bin/wrangler is not a Node.js script. It is a bash script.
So by writing node -r dotenv/config node_modules/.bin/wrangler you are trying to run a bash script as a Node.js script, which obviously is not valid JS.

@petebacondarwin
Copy link
Contributor

I'm not sure what the requirement for node -r dotenv/config is...?

@isaac-mcfadyen
Copy link
Contributor Author

Oh! The comment that I went off of must have been using the original wrangler.

The only other option for passing in environment variables from a .env file that I could see was to use --binding $(cat .env) but that messes up quotations inside the .env file. Is there any options to directly use a .env file (I know that was planned at one point?)

@petebacondarwin
Copy link
Contributor

I haven't seen any discussion of this other than #190, which you already mentioned.

@petebacondarwin
Copy link
Contributor

As a workaround you could try using the following:

node -r dotenv/config node_modules/wrangler/bin/wrangler.js pages dev ./.svelte-kit/cloudflare

But that files does some crazy stuff to turn on --experimental-vm-modules which I believe is only required for miniflare.
So if that also doesn't work you could go one step further and try:

node -r dotenv/config node_modules/wrangler/wrangler-dist/cli.js pages dev ./.svelte-kit/cloudflare

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