-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Labels
Description
I've been trying to get a simple set of functions setup and running and it keeps failing and I can't figure out why.
My netlify.toml
looks like this:
[build]
command = "npm run build"
functions = "dist"
And my npm run build
command is just netlify-lambda build src
If I run npm run build
locally, everything works just fine.
> npm run build
> api@1.0.0 build /Users/jimnielsen/Sites/jim-nielsen.com/api
> netlify-lambda build src
netlify-lambda: Building functions
Hash: 8faa90c77ae883f3a8c3
Version: webpack 4.30.0
Time: 1117ms
Built at: 04/16/2019 4:04:00 PM
Asset Size Chunks Chunk Names
hello.js 1.03 KiB 0 [emitted] hello
icg-slack-deploy.js 18.5 KiB 1 [emitted] icg-slack-deploy
Entrypoint hello = hello.js
Entrypoint icg-slack-deploy = icg-slack-deploy.js
[0] external "stream" 42 bytes {1} [built]
[1] external "zlib" 42 bytes {1} [built]
[2] external "url" 42 bytes {1} [built]
[3] external "http" 42 bytes {1} [built]
[4] external "https" 42 bytes {1} [built]
[5] ./hello.js 123 bytes {0} [built]
[6] ./icg-slack-deploy.js 2.19 KiB {1} [built]
[7] ../node_modules/node-fetch/lib/index.mjs 39.6 KiB {1} [built]
But as soon as I push, the build fails:
3:55:55 PM: Executing user command: npm run build
3:55:56 PM: > api@1.0.0 build /opt/build/repo
3:55:56 PM: > netlify-lambda build src
3:55:56 PM: netlify-lambda: Building functions
3:55:58 PM: Hash: a6669134aaaa082f8a2e
3:55:58 PM: Version: webpack 4.30.0
3:55:58 PM: Time: 1634ms
3:55:58 PM: Built at: 04/16/2019 9:55:58 PM
3:55:58 PM: Asset Size Chunks Chunk Names
3:55:58 PM: hello.js 1.03 KiB 0 [emitted] hello
3:55:58 PM: icg-slack-deploy.js 19.5 KiB 1 [emitted] icg-slack-deploy
3:55:58 PM: Entrypoint hello = hello.js
3:55:58 PM: Entrypoint icg-slack-deploy = icg-slack-deploy.js
3:55:58 PM: [0] external "stream" 42 bytes {1} [built]
3:55:58 PM: [1] external "zlib" 42 bytes {1} [built]
3:55:58 PM: [2] external "url" 42 bytes {1} [built]
3:55:58 PM: [3] external "http" 42 bytes {1} [built]
3:55:58 PM: [4] external "https" 42 bytes {1} [built]
3:55:58 PM: [5] ./hello.js 123 bytes {0} [built]
3:55:58 PM: [6] ./icg-slack-deploy.js 2.19 KiB {1} [built]
3:55:58 PM: [7] ../node_modules/dotenv/lib/main.js 2.87 KiB {1} [built]
3:55:58 PM: [8] external "fs" 42 bytes {1} [built]
3:55:58 PM: [9] external "path" 42 bytes {1} [built]
3:55:58 PM: [10] ../node_modules/node-fetch/lib/index.mjs 39.6 KiB {1} [built]
3:55:58 PM: Build script success
3:55:58 PM: Starting to prepare functions from '/'
3:55:58 PM: Zipping functions from /opt/build/repo/dist to /tmp/zisi-940663858
3:56:04 PM: Error: Could not find "encoding" module in file: /repo/dist/icg-slack-deploy.js.
Please ensure "encoding" is installed in the project.
3:56:04 PM: Failing build: Failed to prepare functions for deployment
3:56:04 PM: failed during stage 'preparing functions for deployment': exit status 1
3:56:05 PM: Finished processing build request in 23.159125539s
3:56:05 PM: Shutting down logging, 0 messages pending
This is the interesting line to me: "Could not find "encoding" module in file: /repo/dist/icg-slack-deploy.js."
What's interesting is that I am only require
ing one dependency in that file:
const fetch = require('node-fetch');
That line of code is making everything fail. If I comment that file out, Netlify builds everything as expected (but then the function doesn't work, because I can't use fetch
).
Am I missing something here?
bomzj