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 build.sh
under /lib/
and for both Functions under /packages/
. Each build.sh
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.
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!
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.
Copied solution after some troubleshooting with Bobby:
I think I have pinpointed the problem. If there is a
build.sh
script in thelib
folder and it doesn’t have execute permission, then the JSON error is shown in the build logs. After runningthe 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
build.sh
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 to17.x
. If no version is specified in your app, App Platform defaults to using version16.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.
That way you will be able to use the new Node.js version.
Let me know how it goes!
Best,
Bobby