Netlify tries to build my function first and does not cd into previous dir after build succeed

Hey,

I don’t observe the same behavior on my local. I’m using the following command:

[build]
base = "./"
command = "pushd web3/ && npm run build && npm run export && popd && pushd functions/ && go build -o api ./cmd && popd"
publish = "web3/out/"

[build.environment]
GO_VERSION = "1.17"
GO_IMPORT_PATH = "github.com/Dentrax/myapp/functions"

[functions]
directory = "functions/"

On my local:

$ netlify build

builds successfully. But if I commit to my repo, here is how netlify tries to build:

11:02:34 AM: $ pushd web3/ && npm run build && npm run export && popd && pushd functions/ && go build -o api ./cmd && popd
11:02:34 AM: ~/.gimme_cache/gopath/src/github.com/Dentrax/myapp/functions/web3 ~/.gimme_cache/gopath/src/github.com/Dentrax/myapp/functions
11:02:34 AM: > myapp@0.1.0 build
11:02:34 AM: > next build
11:02:34 AM: sh: 1: next: not found

Please notice that, myapp/functions/web3 is wrong. i expect myapp/web3 instead. So I ended up Netlify build fails because it first try to build my function first. Instead, it should build the web3 dir instead by issuing next build command.

My config on build settings:

Base directory
    Not set
Build command
    Not set
Publish directory
    Not set

Root dir:

./
├── .git/
├── .netlify/
├── functions/
├── netlify.toml
└── web3/

Any thoughts?

Hey there, @Dentrax

Sorry for the delay here. Can you confirm if the next.js is installed in your package.json? next: not found makes me wonder if we are dealing with an installation issue.

Additionally, can you confirm where your package.json is located? if the package.json exists in the web3 folder, you can move the package.json out of the folder and it should resolve this issue.