I have one project that I can deploy two different ways. The first one works, the second does not.
I used netlify functions:create
to start. This generated a folder (pgnfen) within the /functions folder. Within that was a node_modules folder. I used yarn to add one or two other packages within the new function folder. The /functions/pgnfen/package.json file is now:
{
"name": "apollo-graphql",
"version": "1.0.0",
"description": "netlify functions:create - set up for apollo graphql",
"main": "pgnfen.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"netlify",
"serverless",
"js",
"apollo"
],
"author": "Netlify",
"license": "MIT",
"dependencies": {
"apollo-server-lambda": "^2.4.8",
"firebase-admin": "^8.6.1",
"graphql": "^14.1.1"
}
}
Now the two deploy scenarios:
WORKING: netlify deploy --prod
(after yarn build
)
I can go to my app on the netlify site, press a button, and verify that the function is called and a result is obtained.
Here’s the console output:
➜ pgnfen2 git:(master) ✗ netlify deploy --prod git:(master|✚1
Deploy path: /home/jlowery2663/projects/pgnfen2/build
Functions path: /home/jlowery2663/projects/pgnfen2/functions
Configuration path: /home/jlowery2663/projects/pgnfen2/netlify.toml
Deploying to live site URL...
✔ Finished hashing 16 files and 1 functions
✔ CDN requesting 0 files and 0 functions
✔ Finished uploading 0 assets
✔ Deploy is live!
Logs: https://app.netlify.com/sites/nervous-swirles-c221b3/deploys/5db8a89200842694bd3531df
Unique Deploy URL: https://5db8a89200842694bd3531df--nervous-swirles-c221b3.netlify.com
Live URL: https://nervous-swirles-c221b3.netlify.com
and the deploy log
1:38:33 PM: Starting post processing
1:38:33 PM: Post processing done
1:38:34 PM: Site is live
I can verify that the lambda function is called from within my React app and returns a result.
NOT WORKING: github auto-deploy (or whatever it’s called)
So now when I check in this branch to my github project, and deployment is kicked off. There’s only the deploy log to look at, and it shows an error:
1:40:17 PM: Build ready to start
1:40:21 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
1:40:21 PM: build-image tag: v3.3.2
1:40:21 PM: buildbot version: a2bab682ae0761baa4d123ebd00c57be933655dc
1:40:21 PM: Fetching cached dependencies
1:40:21 PM: Starting to download cache of 177.6MB
1:40:23 PM: Finished downloading cache in 2.076004656s
1:40:23 PM: Starting to extract cache
1:40:30 PM: Finished extracting cache in 6.925075534s
1:40:30 PM: Finished fetching cache in 9.109137273s
1:40:30 PM: Starting to prepare the repo for build
1:40:30 PM: Preparing Git Reference refs/heads/master
1:40:32 PM: Found netlify.toml. Overriding site configuration
1:40:32 PM: Different build command detected, going to use the one specified in the toml file: 'yarn build' versus 'npm run build' in the site
1:40:32 PM: Different functions path detected, going to use the one specified in the toml file: 'functions' versus '/functions' in the site
1:40:32 PM: Creating functions prep folder
1:40:32 PM: Starting build script
1:40:32 PM: Installing dependencies
1:40:32 PM: Started restoring cached node version
1:40:35 PM: Finished restoring cached node version
1:40:37 PM: v10.17.0 is already installed.
1:40:38 PM: Now using node v10.17.0 (npm v6.11.3)
1:40:38 PM: Attempting ruby version 2.6.2, read from environment
1:40:40 PM: Using ruby version 2.6.2
1:40:40 PM: Using PHP version 5.6
1:40:40 PM: Started restoring cached node modules
1:40:40 PM: Finished restoring cached node modules
1:40:40 PM: Started restoring cached yarn cache
1:40:40 PM: Finished restoring cached yarn cache
1:40:41 PM: Installing NPM modules using Yarn version 1.17.0
1:40:42 PM: yarn install v1.17.0
1:40:42 PM: [1/4] Resolving packages...
1:40:43 PM: [2/4] Fetching packages...
1:41:05 PM: info fsevents@2.0.7: The platform "linux" is incompatible with this module.
1:41:05 PM: info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
1:41:05 PM: info fsevents@1.2.9: The platform "linux" is incompatible with this module.
1:41:05 PM: info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
1:41:05 PM: [3/4] Linking dependencies...
1:41:05 PM: warning " > @apollo/react-hooks@3.1.3" has unmet peer dependency "@types/react@^16.8.0".
1:41:05 PM: warning " > @apollo/react-hooks@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
1:41:05 PM: warning "@apollo/react-hooks > @apollo/react-common@3.1.3" has unmet peer dependency "@types/react@^16.8.0".
1:41:05 PM: warning "@apollo/react-hooks > @apollo/react-common@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
1:41:05 PM: warning "@apollo/react-hooks > @apollo/react-common@3.1.3" has unmet peer dependency "apollo-utilities@^1.3.2".
1:41:05 PM: warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
1:41:16 PM: [4/4] Building fresh packages...
1:41:17 PM: Done in 35.35s.
1:41:17 PM: NPM modules installed using Yarn
1:41:17 PM: Started restoring cached go cache
1:41:17 PM: Finished restoring cached go cache
1:41:17 PM: unset GOOS;
1:41:17 PM: unset GOARCH;
1:41:17 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
1:41:17 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
1:41:17 PM: go version >&2;
1:41:17 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
1:41:18 PM: go version go1.12 linux/amd64
1:41:18 PM: Installing missing commands
1:41:18 PM: Verify run directory
1:41:18 PM: Executing user command: yarn build
1:41:18 PM: yarn run v1.17.0
1:41:18 PM: $ react-scripts build
1:41:20 PM: Creating an optimized production build...
1:41:40 PM: Compiled successfully.
1:41:40 PM: File sizes after gzip:
1:41:41 PM: 83.11 KB build/static/js/2.c0fb9c7e.chunk.js
1:41:41 PM: 1.67 KB build/static/js/main.69de7e3c.chunk.js
1:41:41 PM: 956 B build/static/css/main.8a589f20.chunk.css
1:41:41 PM: 771 B build/static/js/runtime-main.c542b234.js
1:41:41 PM: The project was built assuming it is hosted at the server root.
1:41:41 PM: You can control this with the homepage field in your package.json.
1:41:41 PM: For example, add this to build it for GitHub Pages:
1:41:41 PM: "homepage" : "http://myname.github.io/myapp",
1:41:41 PM: The build folder is ready to be deployed.
1:41:41 PM: You may serve it with a static server:
1:41:41 PM: yarn global add serve
1:41:41 PM: serve -s build
1:41:41 PM: Find out more about deployment here:
1:41:41 PM: https://bit.ly/CRA-deploy
1:41:41 PM: Done in 22.76s.
1:41:41 PM: Function Dir: /opt/build/repo/functions
1:41:41 PM: TempDir: /tmp/zisi-5db8a3b14465180008fb5a5e
1:41:41 PM: Prepping functions with zip-it-and-ship-it 0.3.1
1:41:42 PM: Error: Could not find “apollo-server-lambda” module in file: /pgnfen/pgnfen.js.
1:41:42 PM: Please ensure “apollo-server-lambda” is installed in the project.
1:41:42 PM: Error prepping functions
1:41:42 PM: Error running command: Build script returned non-zero exit code: 1
1:41:42 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
1:41:42 PM: Failing build: Failed to build site
1:41:42 PM: Finished processing build request in 1m21.761334898s
I don’t want to use netlify-lambda or zip-it-and-ship-it (directly), and I can go forward with the CLI deployments, but I thought I should bring it to your attention. I appreciate all the support given to me in the past.