Netlify Function not being detected

I’ve set up project where the root contains two folders ‘client’ and ‘server’ and I have two separate package.jsons in each of them. When deploying, I have a prebuild command on the client that runs first that goes into the server folder and builds the function like so: cd ../server && npm i && npm run build which runs my build command in my server folder: run-p build:**

But I don’t get a function from the logs?

6:34:59 PM: Build ready to start
6:35:05 PM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
6:35:05 PM: build-image tag: v3.3.5
6:35:05 PM: buildbot version: 6067c60f3bc043bb6b9ee9b57c85b10029c65bfd
6:35:05 PM: Fetching cached dependencies
6:35:05 PM: Starting to download cache of 169.0MB
6:35:06 PM: Finished downloading cache in 1.06245671s
6:35:06 PM: Starting to extract cache
6:35:12 PM: Finished extracting cache in 5.797936132s
6:35:12 PM: Finished fetching cache in 6.976693357s
6:35:12 PM: Starting to prepare the repo for build
6:35:13 PM: Preparing Git Reference refs/heads/master
6:35:13 PM: Creating functions prep folder
6:35:13 PM: Starting build script
6:35:13 PM: Installing dependencies
6:35:14 PM: Started restoring cached node version
6:35:16 PM: Finished restoring cached node version
6:35:17 PM: v10.18.1 is already installed.
6:35:18 PM: Now using node v10.18.1 (npm v6.13.4)
6:35:18 PM: Attempting ruby version 2.6.2, read from environment
6:35:20 PM: Using ruby version 2.6.2
6:35:20 PM: Using PHP version 5.6
6:35:20 PM: Started restoring cached node modules
6:35:20 PM: Finished restoring cached node modules
6:35:20 PM: Installing NPM modules using NPM version 6.13.4
6:35:34 PM: npm
6:35:34 PM:  WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/chokidar/node_modules/fsevents):
6:35:34 PM: npm
6:35:34 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:35:34 PM: npm WARN
6:35:34 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/jest-haste-map/node_modules/fsevents):
6:35:34 PM: npm WARN
6:35:34 PM: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:35:34 PM: npm WARN
6:35:34 PM:  optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
6:35:34 PM: npm
6:35:34 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:35:34 PM: audited 906642 packages in 12.68s
6:35:35 PM: 34 packages are looking for funding
6:35:35 PM:   run `npm fund` for details
6:35:35 PM: found 0 vulnerabilities
6:35:35 PM: NPM modules installed
6:35:35 PM: Started restoring cached go cache
6:35:35 PM: Finished restoring cached go cache
6:35:35 PM: unset GOOS;
6:35:35 PM: unset GOARCH;
6:35:35 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
6:35:35 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
6:35:35 PM: go version >&2;
6:35:35 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
6:35:35 PM: go version go1.12 linux/amd64
6:35:35 PM: Installing missing commands
6:35:35 PM: Verify run directory
6:35:35 PM: Executing user command: npm run build
6:35:36 PM: > ecommerce-project@0.1.0 prebuild /opt/build/repo/client
6:35:36 PM: > cd ../server && npm i && npm run build
6:35:53 PM: > core-js@2.6.11 postinstall /opt/build/repo/server/node_modules/@babel/polyfill/node_modules/core-js
6:35:53 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:35:54 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
6:35:54 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
6:35:54 PM: > https://opencollective.com/core-js 
6:35:54 PM: > https://www.patreon.com/zloirock 
6:35:54 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
6:35:54 PM: > core-js@3.6.4 postinstall /opt/build/repo/server/node_modules/core-js
6:35:54 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:35:54 PM: > @apollo/protobufjs@1.0.3 postinstall /opt/build/repo/server/node_modules/@apollo/protobufjs
6:35:54 PM: > node scripts/postinstall
6:35:54 PM: > nodemon@1.19.4 postinstall /opt/build/repo/server/node_modules/nodemon
6:35:54 PM: > node bin/postinstall || exit 0
6:35:54 PM: Love nodemon? You can now support the project via the open collective:
6:35:54 PM:  > https://opencollective.com/nodemon/donate
6:35:55 PM: npm
6:35:55 PM:  WARN ecommerce-project-backend@1.0.0 No description
6:35:55 PM: npm
6:35:55 PM: WARN ecommerce-project-backend@1.0.0 No repository field.
6:35:55 PM: npm
6:35:55 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
6:35:55 PM: npm
6:35:55 PM:  WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:35:55 PM: added 809 packages from 509 contributors and audited 11275 packages in 18.522s
6:35:56 PM: 25 packages are looking for funding
6:35:56 PM:   run `npm fund` for details
6:35:56 PM: found 0 vulnerabilities
6:35:56 PM: > ecommerce-project-backend@1.0.0 build /opt/build/repo/server
6:35:56 PM: > run-p build:**
6:35:57 PM: > ecommerce-project-backend@1.0.0 build:lambda /opt/build/repo/server
6:35:57 PM: > netlify-lambda build src/lambda --config webpack.functions.js
6:35:57 PM: netlify-lambda: Building functions
6:35:59 PM: Hash: 2dc6663f4f033cf89a7e
6:35:59 PM: Version: webpack 4.41.5
6:35:59 PM: Time: 905ms
6:35:59 PM: Built at: 01/15/2020 11:35:59 PM
6:35:59 PM:      Asset      Size  Chunks             Chunk Names
6:35:59 PM: graphql.js  1.25 KiB       0  [emitted]  graphql
6:35:59 PM: Entrypoint graphql = graphql.js
6:35:59 PM: [0] external "apollo-server-lambda" 42 bytes {0} [built]
6:35:59 PM: [1] ./graphql.js 403 bytes {0} [built]
6:35:59 PM: > ecommerce-project@0.1.0 build /opt/build/repo/client
6:35:59 PM: > react-scripts build
6:36:01 PM: Creating an optimized production build...
6:36:09 PM: Compiled successfully.
6:36:09 PM: File sizes after gzip:
6:36:09 PM:   39.84 KB  build/static/js/2.a61b510f.chunk.js
6:36:09 PM:   777 B     build/static/js/runtime-main.c57e542c.js
6:36:09 PM:   618 B     build/static/js/main.7bd4c33b.chunk.js
6:36:09 PM:   547 B     build/static/css/main.d1b05096.chunk.css
6:36:09 PM: The project was built assuming it is hosted at the server root.
6:36:09 PM: You can control this with the homepage field in your package.json.
6:36:09 PM: For example, add this to build it for GitHub Pages:
6:36:09 PM:   "homepage" : "http://myname.github.io/myapp",
6:36:09 PM: The build folder is ready to be deployed.
6:36:09 PM: You may serve it with a static server:
6:36:09 PM:   npm install -g serve
6:36:09 PM:   serve -s build
6:36:09 PM: Find out more about deployment here:
6:36:09 PM:   bit.ly/CRA-deploy
6:36:09 PM: Function Dir: /opt/build/repo/client/server
6:36:09 PM: Skipping functions preparation step: /opt/build/repo/client/server not found
6:36:09 PM: Caching artifacts
6:36:09 PM: Started saving node modules
6:36:09 PM: Finished saving node modules
6:36:09 PM: Started saving pip cache
6:36:09 PM: Finished saving pip cache
6:36:09 PM: Started saving emacs cask dependencies
6:36:09 PM: Finished saving emacs cask dependencies
6:36:09 PM: Started saving maven dependencies
6:36:09 PM: Finished saving maven dependencies
6:36:09 PM: Started saving boot dependencies
6:36:09 PM: Finished saving boot dependencies
6:36:09 PM: Started saving go dependencies
6:36:09 PM: Finished saving go dependencies
6:36:10 PM: Starting post processing
6:36:09 PM: Build script success
6:36:09 PM: Starting to deploy site from 'client/build'
6:36:09 PM: Creating deploy tree 
6:36:09 PM: 0 new files to upload
6:36:09 PM: 0 new functions to upload
6:36:10 PM: Post processing done
6:36:10 PM: Site is live
6:36:35 PM: Finished processing build request in 1m30.36068023s

Hi, @Bungkai. It appears that the following log lines might provide some insight about the issue:

6:36:09 PM: Function Dir: /opt/build/repo/client/server
6:36:09 PM: Skipping functions preparation step: /opt/build/repo/client/server not found

My best guess is that the base directory for this Netlify site is set to be client and that the Functions directory is set to be server. However, this is being searched for within the base directory so this becomes client/server within the cloned repo directory (which is /opt/build/repo/).

If the actual Functions directory is server not client/server then changing the Functions directory setting to ../server might resolve this issue. Would you please test this?

If this doesn’t work or if there are other questions, please let us know.