Home
Support Forums

Eleventy config with algoliasearch doesn't get build

I’m trying to deploy my site, this was working until I decided to add in the eleventy config for ‘algoliasearch’
This configuration is working on my local pc . but when I deploy it to Netlify, it errors with
Error: Cannot find module ‘algoliasearch’

details as below:

 ┌───────────────────────────────────┐
8:15:39 PM: │ 1. Build command from Netlify app │
8:15:39 PM: └───────────────────────────────────┘
8:15:39 PM: ​
8:15:39 PM: $ eleventy --serve
8:15:39 PM: Eleventy fatal error: (more in DEBUG output)
8:15:39 PM: > Error in your Eleventy config file '/opt/build/repo/.eleventy.js'. You may need to run `npm install`.
8:15:39 PM: `EleventyConfigError` was thrown
8:15:39 PM: > Cannot find module 'algoliasearch'
8:15:39 PM: Require stack:
8:15:39 PM: - /opt/build/repo/.eleventy.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateConfig.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/Config.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateEngineManager.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/EleventyExtensionMap.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateRender.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateData.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/src/Eleventy.js
8:15:39 PM: - /opt/build/repo/node_modules/@11ty/eleventy/cmd.js
8:15:39 PM: `Error` was thrown:
8:15:39 PM:     Error: Cannot find module 'algoliasearch'
8:15:39 PM:     Require stack:
8:15:39 PM:     - /opt/build/repo/.eleventy.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateConfig.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/Config.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateEngineManager.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/EleventyExtensionMap.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateRender.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/TemplateData.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/src/Eleventy.js
8:15:39 PM:     - /opt/build/repo/node_modules/@11ty/eleventy/cmd.js
8:15:39 PM:         at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
8:15:39 PM:         at Function.Module._load (internal/modules/cjs/loader.js:842:27)
8:15:39 PM:         at Module.require (internal/modules/cjs/loader.js:1026:19)
8:15:39 PM:         at require (internal/modules/cjs/helpers.js:72:18)
8:15:39 PM:         at Object.<anonymous> (/opt/build/repo/.eleventy.js:2:23)
8:15:39 PM:         at Module._compile (internal/modules/cjs/loader.js:1138:30)
8:15:39 PM:         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
8:15:39 PM:         at Module.load (internal/modules/cjs/loader.js:986:32)
8:15:39 PM:         at Function.Module._load (internal/modules/cjs/loader.js:879:14)
8:15:39 PM:         at Module.require (internal/modules/cjs/loader.js:1026:19)

However, this is working on my local machine . I’m new to this, so please do help me or let me know how to begin to fix this error !!

Many thanks,
Chandan.

This might not be something that would fix your issue, but, you’ve a serious problem there. You’re using the command eleventy --serve which is supposed to be the development build of the website and not the final one. Build using the eleventy command.

About the actual error though, it’s hard for me to guess as I have never used Eleventy. However, from the looks of it, it seems like the module with the name algoliasearch was not found. It depends what a module is for Eleventy. However, in case it’s a simple Node Module, maybe, you didn’t include it in your package.json?

That’s what I can guess, but, if you have included that module in your package.json, do you might sharing your repository link so others can check what’s going wrong?

Many thanks Hrishikesh,
It was the missing entry in package.json that did the trick.
I had to include:
“dependencies”: {
“algoliasearch”: “^3.35.1”
}

2 Likes