Svelte 'Sapper' build not recognizing JS optional chaining operators in Netlify

When I git push and netlify starts building my sapper app I keep getting failed builds due to netlify not recognizing that JS optional chaining operators exist…dunno why…

If I build myself and manually deploy to Netlify it works just fine…

I will have on optional chaining operator in my code somewhere , like this:

let overlay = scales[scaleName]?.overlay;

…and during the deployment build netlify will fail with an error like this:

…just to reiterate, when I run the same command ‘npm run export’ on my local machine it all works just fine, I then drag and drop the folder manually into netlify and it runs just fine, and if I comment out the optional chaining operators, then it builds just fine inside netlify…

It seems as if the sapper build process inside of netlify simply does not know what optional chaining operators are…i guess…

Anyway, please advise, and/or fix…thank you :slight_smile:

Here is a link to the deploy log, if you need it:

https://app.netlify.com/sites/nervous-easley-8c62a4/deploys/6045207edf4b590008a805e5

Hey there, @rchrdnsh :wave:

Sorry for the delayed response here. Welcome to the Netlify Forums :netliconfetti:

Is this still an ongoing issue for you? If it has been resolved in the past 8 days, please let us know! If it is still occurring, please confirm and I will share this thread with a member of our team who is more familiar with Sapper.

Thank you,
Hillary

Hi Hillary,

Yes, it is still happening for me…thank you for sharing :slight_smile:

Richard

Hey there! If it’s working locally but not remotely, are you ensuring that your versions locally and remotely match? You might find this guide useful as starters-for-10!

1 Like

My apologies, but I don’t quite fully understand…

So, I git push to github and that kicks off the build process of one version of the site, where the build fails in netlify. I then immediately run npm run export on my local machine and take the output folder and drag and drop that folder onto another version of the site in netlify and that works just fine…not sure if that is what you meant by the versions being the same?

If you mean the node version…I don’t understand the instructions here:

I’m running Node 15.11.0 on my machine, which is far far newer than 12.18.0, so maybe that’s the issue?
Anyway, if that is the case, I don’t know how to ‘set the node.js environment’ to something else, or really any of the instructions in that section…

If you have any more clarification for me that would be great :slight_smile:

Hey!

Yep, the node version (and other dependency versions) need parity :slight_smile:

You can set the NODE_ENV in one of 3 different locations. We have a guide on this too!

The easiest location is the environment variables section of the UI:

  • Site settings > Build & deploy > Environment > Environment variables

Where you’ll set NODE_VERSION to 15.11

ok, some progress!

so I put NODE_VERSION = 15.11 in the environment variable section and that seems to have removed the first error…

…but now…

…I’m getting a new error based on the build not resolving nested imports:

…which makes no sense as far as I can tell, as these work fine in the local export, and I have checked them for accuracy many times…

…any thoughts on that one?

I see a capital letter! Therefore, I think this guide is gonna help you out a little bit now :wink:

Hopefully it’s as trivial as this… do let me know if it helps!

well, never was able to figure it out, but I’m dropping Sapper anyway in favor of Svelte-Kit, so I will close this out :slight_smile:

hmmm…any way to close these out in the forum?

yup - we can mark threads as resolved so I’ve done so. Sorry we didn’t find a solution but thanks for the follow up that you weren’t waiting anymore!