Cannot build site

Hello,

I have some issues when deploying my serverless functions to netlify.

First, the package dotenv seems to be missing from one function, even though I did make the postinstall command recommended with the netlify-lambda install command to install dependencies of each functions. Then, it seems that the functions cannot be uploaded, I have a message Failed to upload file.

I saw when searching that it could be from my env variables name, so I changed these but so far, no luck.

Here is the log below of the two bugs.

Thanks by advance for your help !

2:31:55 PM: > alias-gandi-angular@0.1.0 build:lambda /opt/build/repo
2:31:55 PM: > netlify functions:build --src netlify/lambdas
2:31:56 PM: ◈ Building functions
2:31:56 PM: ◈ Functions built to  /opt/build/repo/api
2:31:57 PM: (node:1293) UnhandledPromiseRejectionWarning: Error: Could not find "dotenv" module in file: /aliases/aliases.js.
2:31:57 PM: Please ensure "dotenv" is installed in the project.
2:31:57 PM:     at handle (/opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:76:17)
2:31:57 PM:     at /opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:105:11
2:31:57 PM:     at Array.forEach (<anonymous>)
2:31:57 PM:     at getDependencies (/opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:98:8)
2:31:57 PM:     at filesForFunctionZip (/opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:60:7)
2:31:57 PM:     at zipJs (/opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:113:3)
2:31:57 PM:     at zipFunction (/opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:146:12)
2:31:57 PM:     at /opt/build/repo/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:184:9
2:31:57 PM:     at /opt/build/repo/node_modules/p-all/index.js:4:67
2:31:57 PM:     at /opt/build/repo/node_modules/p-map/index.js:47:21
2:31:57 PM: (node:1293) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2:31:57 PM: (node:1293) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2:31:57 PM: Function Dir: /opt/build/repo/api
2:31:57 PM: TempDir: /tmp/zisi-5e1c71211d9a9295e2de8350
2:31:57 PM: Prepping functions with zip-it-and-ship-it 0.3.1
2:31:58 PM: [
2:31:58 PM:   {
2:31:58 PM:     path: '/tmp/zisi-5e1c71211d9a9295e2de8350/aliases.zip',
2:31:58 PM:     runtime: 'js'
2:31:58 PM:   },
2:31:58 PM:   {
2:31:58 PM:     path: '/tmp/zisi-5e1c71211d9a9295e2de8350/auth.zip',
2:31:58 PM:     runtime: 'js'
2:31:58 PM:   },
2:31:58 PM:   {
2:31:58 PM:     path: '/tmp/zisi-5e1c71211d9a9295e2de8350/domains.zip',
2:31:58 PM:     runtime: 'js'
2:31:58 PM:   },
2:31:58 PM:   {
2:31:58 PM:     path: '/tmp/zisi-5e1c71211d9a9295e2de8350/hello.zip',
2:31:58 PM:     runtime: 'js'
2:31:58 PM:   },
2:31:58 PM:   {
2:31:58 PM:     path: '/tmp/zisi-5e1c71211d9a9295e2de8350/mailbox.zip',
2:31:58 PM:     runtime: 'js'
2:31:58 PM:   }
2:31:58 PM: ]
2:31:58 PM: Prepping functions complete
2:31:58 PM: Caching artifacts
2:31:58 PM: Started saving node modules
2:31:58 PM: Finished saving node modules
2:31:58 PM: Started saving pip cache
2:31:59 PM: Finished saving pip cache
2:31:59 PM: Started saving emacs cask dependencies
2:31:59 PM: Finished saving emacs cask dependencies
2:31:59 PM: Started saving maven dependencies
2:31:59 PM: Finished saving maven dependencies
2:31:59 PM: Started saving boot dependencies
2:31:59 PM: Finished saving boot dependencies
2:31:59 PM: Started saving go dependencies
2:31:59 PM: Finished saving go dependencies
2:31:59 PM: Build script success
2:31:59 PM: Starting to deploy site from 'dist/alias-gandi-angular/'
2:31:59 PM: Creating deploy tree 
2:31:59 PM: 0 new files to upload
2:31:59 PM: 5 new functions to upload
2:34:15 PM: Failed to upload file: &{Name:aliases Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc270}
2:34:23 PM: Failed to upload file: &{Name:aliases Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc270}
2:34:26 PM: Failed to upload file: &{Name:aliases Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc270}
2:34:27 PM: Failed to upload file: &{Name:auth Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc2d0}
2:34:27 PM: Failed to upload file: &{Name:domains Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc330}
2:34:31 PM: Failed to upload file: &{Name:auth Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc2d0}
2:34:37 PM: Failed to upload file: &{Name:domains Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc330}
2:34:37 PM: Failed to upload file: &{Name:mailbox Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc3f0}
2:34:43 PM: Failed to upload file: &{Name:mailbox Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc3f0}
2:34:59 PM: Failed to upload file: &{Name:auth Sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Runtime:js Size:<nil> Path: Buffer:0xc0004dc2d0}
2:34:59 PM: Failing build: Failed to deploy site
2:34:59 PM: failed during stage 'deploying site': Failed to execute deploy: Upload cancelled: auth
2:34:59 PM: Finished processing build request in 3m44.893120003s

Here is my current netlify.toml

[build]
  command = "npm run build"
  publish = "dist/alias-gandi-angular/"
  functions = "./api"

[context.production]
  environment = { NODE_ENV = "production" }

[context.deploy-preview]
    environment = { NODE_ENV = "development" }

[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200

and the postinstall script of my package.json

    "postinstall": "netlify-lambda install netlify/lambdas"

I switched to a single package.json instead of multiples one, which seem to solve the issue.

1 Like

we likely would have suggested that, glad it fixed your issue!