remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.95k stars 2.53k forks source link

Deploying via Cloudflare Pages, unexpected token error #3095

Closed dlbone closed 1 year ago

dlbone commented 2 years ago

What version of Remix are you using?

1.3.1

Steps to Reproduce

Deploy a repo through Cloudflare pages.

Expected Behavior

For it to build and deploy.

Actual Behavior

The error received during build was:

15:48:45.508 | > remix setup node 15:48:45.509 |   15:48:45.603 | /opt/buildhome/repo/node_modules/@remix-run/dev/cli.js:325 15:48:45.603 | appTemplate: flags.template ?? answers.appTemplate, 15:48:45.603 | ^ 15:48:45.603 |   15:48:45.603 | SyntaxError: Unexpected token '?' 15:48:45.604 | at wrapSafe (internal/modules/cjs/loader.js:1054:16) 15:48:45.604 | at Module._compile (internal/modules/cjs/loader.js:1102:27) 15:48:45.604 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) 15:48:45.604 | at Module.load (internal/modules/cjs/loader.js:986:32) 15:48:45.604 | at Function.Module._load (internal/modules/cjs/loader.js:879:14) 15:48:45.604 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) 15:48:45.604 | at internal/main/run_main_module.js:17:47 15:48:45.625 | npm ERR! code ELIFECYCLE 15:48:45.626 | npm ERR! errno 1 15:48:45.627 | npm ERR! remix-app-template-js@ postinstall: remix setup node 15:48:45.627 | npm ERR! Exit status 1

Alext162 commented 2 years ago

I am receiving the same error - did you manage to find a fix?

grayendeavours commented 2 years ago

I had a similar issue that I fixed by setting env var NODE_VERSION to v16.7.0, seen on the Pages docs for Remix. Docs only mention setting it for production but needs to be set for preview builds too.

machour commented 1 year ago

This looks indeed like a node version issue, nothing that can be done on Remix side

https://developers.cloudflare.com/pages/framework-guides/deploy-a-remix-site/#deploying-with-cloudflare-pages