Functions deployment error: Unexpected token › in JSON at position 0

I am trying to deploy two Functions that are a component of an app in the App Platform. I keep getting this error:

[2023-09-22 22:33:41] │ Failures:
[2023-09-22 22:33:41] │  ›   Error: While deploying 'get-leaderboard-entries' (running remote build): 
[2023-09-22 22:33:41] │  ›   Unexpected token › in JSON at position 0
[2023-09-22 22:33:41] │  ›   Error: While deploying 'save-new-top-time' (running remote build): 
[2023-09-22 22:33:41] │  ›   Unexpected token › in JSON at position 0
[2023-09-22 22:33:42] │ 
[2023-09-22 22:33:42] │ command exited with code 1
[2023-09-22 22:33:42] │ 
[2023-09-22 22:33:42] │  ✘ build failed

I have cleared the top level directory of the Functions project so all that is left is:

  • /lib/
  • /packages/
  • /.gitignore
  • /project.yml

I have a under /lib/ and for both Functions under /packages/ . Each basically does

npm install
npm run build

All package.json and tsconfig.json files don’t seem to have any invalid syntax.

Running doctl sls deploy --remote-build works though.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Copied solution after some troubleshooting with Bobby:

I think I have pinpointed the problem. If there is a script in the lib folder and it doesn’t have execute permission, then the JSON error is shown in the build logs. After running

git add --chmod=+x --

the build should either be able to finish or error out with code 126. If you get error code 126, then you’ll probably need to run the same command for the other scripts. Tried this command after searching around and found this.

Hi there,

What is the Node.js version that you are using on the App Platform?

The Default Buildpack Stack on the App Platform uses version 0.3.6 of the Node.js Cloud Native Buildpack by default. The buildpack supports Node.js runtime versions up to 17.x. If no version is specified in your app, App Platform defaults to using version 16.x.

Based on the error, I think that you might need at least Node.js 18.x. You can choose to build and deploy apps using the upcoming Ubuntu 22.04 stack by adding the specified app spec feature to the root of your app spec.

    - buildpack-stack=ubuntu-22

That way you will be able to use the new Node.js version.

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel