algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
177 stars 45 forks source link

Error in netlify deploy #126

Closed talmax1124 closed 3 years ago

talmax1124 commented 3 years ago

When using deploy on netlify, gives me error. I tried changing the api key in netlify to see if it was that but no luck.

$ npm run build
11:51:04 PM: > gatsby-starter-delog@1.6.0 build /opt/build/repo
11:51:04 PM: > GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
11:51:08 PM: success open and validate gatsby-configs - 0.077s
11:51:10 PM: error Error in "/opt/build/repo/node_modules/gatsby-plugin-algolia/gatsby-node.js": Invalid or unexpected token
11:51:10 PM:
11:51:10 PM:
11:51:10 PM: Error: /opt/build/repo/node_modules/gatsby-plugin-algolia/gatsby-node.js:47
11:51:10 PM: const client = algoliasearch(appId, apiKey, { timeout: 30_000 });
11:51:10 PM: ^^
11:51:10 PM: SyntaxError: Invalid or unexpected token
11:51:10 PM:
Haroenv commented 3 years ago

are you on an older node version?

talmax1124 commented 3 years ago

@Haroenv No I am not. I even updated the .toml version if that was the error.

Haroenv commented 3 years ago

Is there somewhere I can reproduce this?

talmax1124 commented 3 years ago

Yes, In this repo: https://github.com/talmax1124/gatsby-starter-delog-master

Haroenv commented 3 years ago

While the netlify.toml was updated, the nvmrc wasn't: https://github.com/talmax1124/gatsby-starter-delog-master/pull/2

I forked your site and tried netlify which shows it was using v10 https://app.netlify.com/sites/vibrant-hodgkin-dedbbd/deploys/60742ca74afb2700d3c3946f

talmax1124 commented 3 years ago

How do I update the .nvmrc. Is that what's affecting it? @Haroenv

talmax1124 commented 3 years ago

Ok, I updated it but now it gives me this when I deploy:

7:27:21 AM: 2. build.command from netlify.toml
7:27:21 AM: ──────────────────────────────────────────────────────────────── 7:27:21 AM: ​ 7:27:21 AM: $ npm run build 7:27:21 AM: > gatsby-starter-delog@1.6.0 build /opt/build/repo 7:27:21 AM: > GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages 7:27:24 AM: success open and validate gatsby-configs - 0.096s 7:27:26 AM: error Error in "/opt/build/repo/node_modules/gatsby-plugin-algolia/gatsby-node.js": Cannot find module 'gatsby-cli/lib/reporter' 7:27:26 AM: Require stack: 7:27:26 AM: - /opt/build/repo/node_modules/gatsby-plugin-algolia/gatsby-node.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/load.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/cli.js 7:27:26 AM: 7:27:26 AM: 7:27:26 AM: Error: Cannot find module 'gatsby-cli/lib/reporter' 7:27:26 AM: Require stack: 7:27:26 AM: - /opt/build/repo/node_modules/gatsby-plugin-algolia/gatsby-node.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/load.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.j s 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js 7:27:26 AM: - /opt/build/repo/node_modules/gatsby/cli.js 7:27:26 AM:

talmax1124 commented 3 years ago

Your build failed with the same error as above @Haroenv

Haroenv commented 3 years ago

for that you need to add Gatsby-cli as a dependency, see https://github.com/algolia/gatsby-plugin-algolia/issues/123

talmax1124 commented 3 years ago

Now I have this issue:

7:54:59 AM: failed Building production JavaScript and CSS bundles - 27.824s 7:54:59 AM: error Generating JavaScript bundles failed 7:54:59 AM: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): 7:54:59 AM: Error: Missing binding /opt/build/repo/node_modules/node-sass/vendor/linux-x64-83/binding.node 7:54:59 AM: Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 14.x 7:54:59 AM: Found bindings for the following environments: 7:54:59 AM: - Linux 64-bit with Node.js 10.x 7:54:59 AM: This usually happens because your environment has changed since running npm install. 7:54:59 AM: Run npm rebuild node-sass to download the binding for your current environment. 7:54:59 AM: at module.exports (/opt/build/repo/node_modules/node-sass/lib/binding.js:15:13) 7:54:59 AM: at Object. (/opt/build/repo/node_modules/node-sass/lib/index.js:14:35) 7:54:59 AM: at Module._compile (/opt/build/repo/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) 7:54:59 AM: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) 7:54:59 AM: at Module.load (internal/modules/cjs/loader.js:928:32) 7:54:59 AM: at Function.Module._load (internal/modules/cjs/loader.js:769:14) 7:54:59 AM: at Module.require (internal/modules/cjs/loader.js:952:19) 7:54:59 AM: at require (/opt/build/repo/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) 7:54:59 AM: at getDefaultSassImpl (/opt/build/repo/node_modules/sass-loader/dist/index.js:198:10) 7:54:59 AM: at Object.loader (/opt/build/repo/node_modules/sass-loader/dist/index.js:80:29) 7:54:59 AM: error Generating JavaScript bundles failed 7:54:59 AM: Missing binding /opt/build/repo/node_modules/node-sass/vendor/linux-x64-83/binding.node 7:54:59 AM: Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 14.x 7:54:59 AM: Found bindings for the following environments: 7:54:59 AM: - Linux 64-bit with Node.js 10.x 7:54:59 AM: This usually happens because your environment has changed since running npm install. 7:54:59 AM: Run npm rebuild node-sass to download the binding for your current environment. 7:54:59 AM: npm ERR! code ELIFECYCLE 7:54:59 AM: npm ERR! errno 1 7:54:59 AM: npm ERR! gatsby-starter-delog@1.6.0 build: GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages

@Haroenv I already did a commit with rebuild the sass. Should I just delete the package-lock.json and the node modules and install all again?