Front-End: Unhandled Runtime Error SyntaxError: Unexpected token '?'

Hi All,

I have been trying to setup and run the headless setup powered by the Atlas Add-on and it proving rather difficult. I have encountered quite a few issues.

After having issues with provisioning which eventually worked I got a website installed and running.

I am able to login into the backend without issues.

I have an issue accesing the front end where I am getting:
Unhandled Runtime Error SyntaxError: Unexpected token '?'

My setup is:
Mac Mini macOS Mojave V 10.14.6
Local V 6.1.5
Atlas Add-on V 1.3.0

This is the error displaed:

`1 of 1 unhandled error

Unhandled Runtime Error
SyntaxError: Unexpected token '?'
Call Stack
eval

[native code]
./node_modules/@faustjs/core/dist/mjs/gqty/index.js

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/pages/_app.js (2060:5)
factory

/_next/static/chunks/webpack.js (685:35)
__webpack_require__

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/webpack.js (37:37)
eval

[native code]
./node_modules/@faustjs/core/dist/mjs/export/index.js

/_next/static/chunks/pages/_app.js (2038:5)
factory

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/webpack.js (685:35)
__webpack_require__

/_next/static/chunks/webpack.js (37:37)
eval

[native code]
./src/faust.config.js

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/pages/_app.js (40:5)
factory

/_next/static/chunks/webpack.js (685:35)
__webpack_require__

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/webpack.js (37:37)
eval

[native code]
./src/pages/_app.tsx

/_next/static/chunks/pages/_app.js (51:5)
factory

file:///Users/bc-dev-2/Desktop/LOCAL/XYZATLAS/app-node/.next/static/chunks/webpack.js (685:35)
__webpack_require__

/_next/static/chunks/webpack.js (37:37)
promiseReactionJob

[native code]

I am out of ideas. :man_shrugging:

That error seems like a Webpack compile error.

Towards the bottom, that error mentions:

./src/faust.config.js

which I think is within the site-name/app-node/src/faust.config.js file.

If you open up that file, does it look like valid Javascript?

You might try creating a new Atlas site in Local to see if there was some sort of temporary issue while creating the site.

Hi Ben,

Thank you for you suggestion. I checked the faust.config.js file and it looks ok to me.

Here is the file contents:

import { config as coreConfig } from '@faustjs/core';

if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) {
console.error(
‘You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?’,
);
}

/**

  • @type {import("@faustjs/core").Config}
    */
    export default coreConfig({
    wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
    apiClientSecret: process.env.WP_HEADLESS_SECRET,
    });

I have tried creating numeous other websites as headless setup and two things happen. I either get another error relating to mysql for which I could start another topic or Local completly ignores the fact that I checked the option to install it as headless and instead just creates a new regular WordPress instance. So feel quite lucky that I got one setup as far as it is now. Bankend seems to work good but front is not.

That error mentions that maybe the .env.local file might not be loaded. If you open that file, does it have the NEXT_PUBLIC_WORDPRESS_URL set to the url of the WordPress backend?

Here’s what I have on my machine:

Also, where did you see that error originally? Was it from the “Show Output” button under the “Front-end Node.js” section of the site in Local?

Hi Ben,

In regard to the .env.local file everything checks out ok. The file has the correct value url for backend. Backend of the wordpress is working fine.

The error comes up when I click on OPEN SITE in local. The browser opens and tries to load the website front end. This is when the error is displayed.

Here, I am also attaching the output of the SHOW OUTPUT window. All seems fine there.

Hi Ben,

I should also add that at first instance I am seeing 502 error. When I refresh the page I then see the error which I mentioned in my first post.

I thought this would also give some insight?

And this refers me to inspect the Local Routers Log. I really dont know how to read this file or what to look out for, what to action. I am also attaching the log.

error.log (14.8 KB)

Thank you for all of your time and help.

That 502 error has the styling that I typically associate with Local’s Router – which means that for some reason, it can’t reach the WordPress backend.

In order to get a bit more info about what the Local app is encountering when creating sites, can you please provide your Local Log? See this Community Forum post for instructions on how to do so: