Can I use a github repo in my package.json?

I’m using gatsby-source-google-sheets w/ gatsby 3.3.1, the package needs to accept a merge, so I forked it, and used
npm i jjrchrds/gatsby-source-google-sheets

my package json now has
"gatsby-source-google-sheets": "github:jjrchrds/gatsby-source-google-sheets",

My build works locally with npm run develop and npm run build, but with netlify I am seeing the following:

5:40:38 PM: error There was an error in your GraphQL query:
5:40:38 PM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".

full log below

5:39:01 PM: Build ready to start
5:39:03 PM: build-image version: 7b53c5fc4445e3ec99d3949e5d1174a8c5be4f16
5:39:03 PM: build-image tag: v3.7.2
5:39:03 PM: buildbot version: a8df6d1263bb5bcc16f7b4ebb8e9a6cb904cfa8a
5:39:03 PM: Building without cache
5:39:03 PM: Starting to prepare the repo for build
5:39:04 PM: No cached dependencies found. Cloning fresh repo
5:39:04 PM: git clone https://github.com/jjrchrds/pocam.ca
5:39:05 PM: Preparing Git Reference pull/7/head
5:39:06 PM: Parsing package.json dependencies
5:39:07 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
5:39:07 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'lambda' versus '' in the Netlify UI
5:39:07 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'gatsby build' in the Netlify UI
5:39:07 PM: Starting build script
5:39:07 PM: Installing dependencies
5:39:07 PM: Python version set to 2.7
5:39:08 PM: v12.18.0 is already installed.
5:39:09 PM: Now using node v12.18.0 (npm v6.14.4)
5:39:09 PM: Started restoring cached build plugins
5:39:09 PM: Finished restoring cached build plugins
5:39:09 PM: Attempting ruby version 2.7.1, read from environment
5:39:10 PM: Using ruby version 2.7.1
5:39:11 PM: Using PHP version 5.6
5:39:11 PM: Started restoring cached node modules
5:39:11 PM: Finished restoring cached node modules
5:39:11 PM: Installing NPM modules using NPM version 6.14.4
5:40:08 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
5:40:08 PM: > sharp@0.28.1 install /opt/build/repo/node_modules/gatsby-plugin-manifest/node_modules/sharp
5:40:08 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
5:40:10 PM: sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.6/libvips-8.10.6-linux-x64.tar.br
5:40:11 PM: > sharp@0.28.1 install /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp
5:40:11 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
5:40:12 PM: sharp: Using cached /opt/buildhome/.npm/_libvips/libvips-8.10.6-linux-x64.tar.br
5:40:13 PM: > sharp@0.28.1 install /opt/build/repo/node_modules/gatsby-transformer-sharp/node_modules/sharp
5:40:13 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
5:40:15 PM: sharp: Using cached /opt/buildhome/.npm/_libvips/libvips-8.10.6-linux-x64.tar.br
5:40:16 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@firebase/polyfill/node_modules/core-js
5:40:16 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:40:16 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
5:40:16 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:40:16 PM: > core-js@3.10.2 postinstall /opt/build/repo/node_modules/core-js
5:40:16 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:40:16 PM: > core-js-pure@3.10.2 postinstall /opt/build/repo/node_modules/core-js-pure
5:40:16 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:40:17 PM: > protobufjs@6.10.2 postinstall /opt/build/repo/node_modules/protobufjs
5:40:17 PM: > node scripts/postinstall
5:40:18 PM: > gatsby-telemetry@2.3.0 postinstall /opt/build/repo/node_modules/gatsby-telemetry
5:40:18 PM: > node src/postinstall.js || true
5:40:18 PM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
5:40:18 PM: > node lib/install.js
5:40:18 PM:   βœ” mozjpeg pre-build test passed successfully
5:40:18 PM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
5:40:18 PM: > node lib/install.js
5:40:19 PM:   βœ” pngquant pre-build test passed successfully
5:40:19 PM: > gatsby-cli@3.3.0 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
5:40:19 PM: > node scripts/postinstall.js
5:40:19 PM: > gatsby@3.3.1 postinstall /opt/build/repo/node_modules/gatsby
5:40:19 PM: > node scripts/postinstall.js
5:40:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
5:40:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:40:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
5:40:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:40:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
5:40:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:40:22 PM: added 2914 packages from 1264 contributors and audited 2920 packages in 70.516s
5:40:26 PM: 278 packages are looking for funding
5:40:26 PM:   run `npm fund` for details
5:40:26 PM: found 17 vulnerabilities (2 low, 9 moderate, 6 high)
5:40:26 PM:   run `npm audit fix` to fix them, or `npm audit` for details
5:40:26 PM: NPM modules installed
5:40:26 PM: Started restoring cached go cache
5:40:26 PM: Finished restoring cached go cache
5:40:26 PM: go version go1.14.4 linux/amd64
5:40:26 PM: go version go1.14.4 linux/amd64
5:40:26 PM: Installing missing commands
5:40:26 PM: Verify run directory
5:40:28 PM: ​
5:40:28 PM: ────────────────────────────────────────────────────────────────
5:40:28 PM:   Netlify Build                                                 
5:40:28 PM: ────────────────────────────────────────────────────────────────
5:40:28 PM: ​
5:40:28 PM: ❯ Version
5:40:28 PM:   @netlify/build 11.3.2
5:40:28 PM: ​
5:40:28 PM: ❯ Flags
5:40:28 PM:   deployId: 608b2775b9b241744aced803
5:40:28 PM: ​
5:40:28 PM: ❯ Current directory
5:40:28 PM:   /opt/build/repo
5:40:28 PM: ​
5:40:28 PM: ❯ Config file
5:40:28 PM:   /opt/build/repo/netlify.toml
5:40:28 PM: ​
5:40:28 PM: ❯ Context
5:40:28 PM:   deploy-preview
5:40:28 PM: ​
5:40:28 PM: ────────────────────────────────────────────────────────────────
5:40:28 PM:   1. build.command from netlify.toml                            
5:40:28 PM: ────────────────────────────────────────────────────────────────
5:40:28 PM: ​
5:40:28 PM: $ npm run build
5:40:29 PM: > gatsby-starter-hello-world@0.1.0 build /opt/build/repo
5:40:29 PM: > gatsby build && netlify-lambda build src/lambda
5:40:33 PM: success open and validate gatsby-configs - 0.078s
5:40:34 PM: success load plugins - 1.158s
5:40:34 PM: success onPreInit - 0.041s
5:40:34 PM: success initialize cache - 0.006s
5:40:34 PM: success copy gatsby files - 0.058s
5:40:34 PM: success onPreBootstrap - 0.017s
5:40:34 PM: success createSchemaCustomization - 0.008s
5:40:34 PM: success Contentful: Sync all items - 0.060s - 21/1000 16544.38/s
5:40:34 PM: success Contentful: Fetch data (89g5kg306hwd-master) - 0.287s
5:40:34 PM: info Updated entries 18
5:40:34 PM: info Deleted entries 0
5:40:34 PM: info Updated assets 3
5:40:34 PM: info Deleted assets 0
5:40:34 PM: success Contentful: Process data (89g5kg306hwd-master) - 0.018s
5:40:34 PM: info Creating 15 Contentful Commitment Question nodes
5:40:35 PM: info Creating 1 Contentful Call for Equity Page nodes
5:40:35 PM: info Creating 2 Contentful POCAM Team Member nodes
5:40:35 PM: info Creating 3 Contentful asset nodes
5:40:35 PM: success Contentful: Create nodes (89g5kg306hwd-master) - 0.037s
5:40:35 PM: success Checking for changed pages - 0.000s
5:40:35 PM: success source and transform nodes - 0.602s
5:40:35 PM: success building schema - 0.910s
5:40:35 PM: info Total nodes: 155, SitePage nodes: 1 (use --verbose for breakdown)
5:40:35 PM: success createPages - 0.001s
5:40:35 PM: success Checking for changed pages - 0.000s
5:40:36 PM: success createPagesStatefully - 0.118s
5:40:36 PM: success update schema - 0.107s
5:40:36 PM: success onPreExtractQueries - 0.002s
5:40:38 PM: error There was an error in your GraphQL query:
5:40:38 PM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".
5:40:38 PM: If you don't expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist on the type "Query" it is most likely a typo.However, if you expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist there are a couple of solutions to common problems:
5:40:38 PM: - If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
5:40:38 PM: - The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
5:40:38 PM: - You want to optionally use your field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")
5:40:38 PM: It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query":https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions
5:40:38 PM: error There was an error in your GraphQL query:
5:40:38 PM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".
5:40:38 PM: If you don't expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist on the type "Query" it is most likely a typo.However, if you expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist there are a couple of solutions to common problems:
5:40:38 PM: - If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
5:40:38 PM: - The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
5:40:38 PM: - You want to optionally use your field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")
5:40:38 PM: It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query":https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions
5:40:38 PM: error There was an error in your GraphQL query:
5:40:38 PM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".
5:40:38 PM: If you don't expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist on the type "Query" it is most likely a typo.However, if you expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist there are a couple of solutions to common problems:
5:40:38 PM: - If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
5:40:38 PM: - The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
5:40:38 PM: - You want to optionally use your field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")
5:40:38 PM: It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query":https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions
5:40:38 PM: error There was an error in your GraphQL query:
5:40:38 PM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".
5:40:38 PM: If you don't expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist on the type "Query" it is most likely a typo.However, if you expect "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" to exist there are a couple of solutions to common problems:
5:40:38 PM: - If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
5:40:38 PM: - The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
5:40:38 PM: - You want to optionally use your field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")
5:40:38 PM: It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query":https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions
5:40:38 PM: failed extract queries from components - 2.217s
5:40:38 PM: npm ERR! code ELIFECYCLE
5:40:38 PM: npm ERR! errno 1
5:40:38 PM: npm ERR! gatsby-starter-hello-world@0.1.0 build: `gatsby build && netlify-lambda build src/lambda`
5:40:38 PM: npm ERR! Exit status 1
5:40:38 PM: npm ERR!
5:40:38 PM: npm ERR! Failed at the gatsby-starter-hello-world@0.1.0 build script.
5:40:38 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:40:38 PM: npm ERR! A complete log of this run can be found in:
5:40:38 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-04-29T21_40_38_478Z-debug.log
5:40:38 PM: ​
5:40:38 PM: ────────────────────────────────────────────────────────────────
5:40:38 PM:   "build.command" failed                                        
5:40:38 PM: ────────────────────────────────────────────────────────────────
5:40:38 PM: ​
5:40:38 PM:   Error message
5:40:38 PM:   Command failed with exit code 1: npm run build
5:40:38 PM: ​
5:40:38 PM:   Error location
5:40:38 PM:   In build.command from netlify.toml:
5:40:38 PM:   npm run build
5:40:38 PM: ​
5:40:38 PM:   Resolved config
5:40:38 PM:   build:
5:40:38 PM:     command: npm run build
5:40:38 PM:     commandOrigin: config
5:40:38 PM:     environment:
5:40:38 PM:       - ADMIN_EMAIL
5:40:38 PM:       - CONTENTFUL_ACCESS_TOKEN
5:40:38 PM:       - FIREBASE_API_KEY
5:40:38 PM:       - FIREBASE_APP_ID
5:40:38 PM:       - MAILCHIMP_ENDPOINT
5:40:38 PM:       - MAILGUN_API_KEY
5:40:38 PM:       - MAILGUN_DOMAIN
5:40:38 PM:       - PRIVATE_KEY
5:40:38 PM:       - REVIEW_ID
5:40:38 PM:       - SPREADSHEET_ID
5:40:38 PM:     publish: /opt/build/repo/public
5:40:38 PM:   functionsDirectory: /opt/build/repo/lambda
5:40:38 PM: Caching artifacts
5:40:38 PM: Started saving node modules
5:40:38 PM: Finished saving node modules
5:40:38 PM: Started saving build plugins
5:40:38 PM: Finished saving build plugins
5:40:38 PM: Started saving pip cache
5:40:39 PM: Finished saving pip cache
5:40:39 PM: Started saving emacs cask dependencies
5:40:39 PM: Finished saving emacs cask dependencies
5:40:39 PM: Started saving maven dependencies
5:40:39 PM: Finished saving maven dependencies
5:40:39 PM: Started saving boot dependencies
5:40:39 PM: Finished saving boot dependencies
5:40:39 PM: Started saving rust rustup cache
5:40:39 PM: Finished saving rust rustup cache
5:40:39 PM: Started saving go dependencies
5:40:39 PM: Finished saving go dependencies
5:40:41 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:40:41 PM: Creating deploy upload records
5:40:41 PM: Failing build: Failed to build site
5:40:41 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
5:40:41 PM: Finished processing build request in 1m38.25943483s

I noticed the package.lock contains:

"node_modules/gatsby-source-google-sheets": {
      "version": "1.1.1",
      "resolved": "git+ssh://git@github.com/jjrchrds/gatsby-source-google-sheets.git#706d81c7dc95be9d619e6757c10dcb180a1a4e0d",
      "license": "MIT",
      "dependencies": {
        "flow-bin": "^0.56.0",
        "google-spreadsheet": "2.0.3",
        "lodash": "^4.17.4",
        "uuid": "^3.1.0"
      }
    },

Is this failing because netlify can’t get to the repo? what solutions do I have?

Hi @jjrchrds

Have you tried using https://github.com/jjrchrds/gatsby-source-google-sheets since it is a public repo?

Otherwise you will have to create the deploy key to access the repo using ssh. You can find those instructions here.

1 Like

if i use npm i https://github.com/jjrchrds/gatsby-source-google-sheets

i see the same result in my package.json and package-lock.json, meaning it reads git+ssh

What’s the correct way to install it?

so using:
"gatsby-source-google-sheets": "git+https://jjrchrds@github.com/jjrchrds/gatsby-source-google-sheets.git",

puts this in my package-lock:
"gatsby-source-google-sheets": "git+https://jjrchrds@github.com/jjrchrds/gatsby-source-google-sheets.git",

But I’m still getting the same error in Netlify
9:47:48 AM: error There was an error in your GraphQL query:
9:47:48 AM: Cannot query field "allGoogleSheetIndustryCallForEquityCommitmentsResponsesRow" on type "Query".

this works fine with npm run develop locally. Even after gatsby clean. Is there a way to check if this package is being loaded?

@jjrchrds not sure what the real problem is here. The jjrchrds/gatsby-source-google-sheets library has a prepublish command for npm publish, so I’m wondering if you have that in the workflow once you have completed the npm install on netlify.

Try replicating the Netlify CI/CD workflow by doing a clone of your main project into a new location locally and seeing if you get the same result as the Netlify build.