Hello,
Just as the title says, my site is running fine in dev mode and builds (locally) to completion, however once deployed (currently deployed manually at netlify) I see the following error.
I am using the gatsby-starter-default starter created with gatsby new.
Uncaught Error: Cannot find module "gatsby-module-loader?name=component---src-templates-article-js!/Users/joshweaver/Documents/BtB Current/Documentation/Static/rollcall-docs/src/templates/article.js"
at async-requires.js:5
at Object.166 (async-requires.js:5)
at t (bootstrap ff971473c0c889c97952:52)
at Object.0 (production-app.js:16)
at t (bootstrap ff971473c0c889c97952:52)
at window.webpackJsonp (bootstrap ff971473c0c889c97952:23)
at app-43a42bdd9167f8645c1f.js:1
Any ideas?
Looks like you hard-coded the absolute path to your template file.
Use path.resolve instead.
Thanks for the quick response!
Well. I had:
const articlePage = path.resolve("src/templates/article.js");
Changing it to:
const articlePage = path.resolve("./src/templates/article.js");
Did not help...
Any other thoughts? Here's my entire gatsby-node.js
const path = require("path");
const _ = require("lodash");
const webpackLodashPlugin = require("lodash-webpack-plugin");
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators;
return new Promise((resolve, reject) => {
graphql(
`
{
allContentfulArticle {
edges {
node {
id
sort
createdAt
updatedAt
title
titleSlug
version {
title
}
topic {
title
titleSlug
}
body {
childMarkdownRemark {
html
timeToRead
}
}
}
}
}
}
`
)
.then(result => {
if (result.errors) {
reject(result.errors);
}
const articlePage = path.resolve("./src/templates/article.js");
if (!result.data) {
console.error("NO Data!");
return;
}
_.each(result.data.allContentfulArticle.edges, edge => {
createPage({
path: `${edge.node.topic.titleSlug}/${edge.node.titleSlug}`,
component: articlePage,
context: {
id: edge.node.id,
slug: edge.node.titleSlug
}
});
});
})
.then(resolve);
});
};
Grep your code for /Users/joshweaver/Documents/.
Somehow or another a path from your local computer is showing up on Netlify which means it has to be in your code somewhere.
Well it's odd because I just cloned my repo and ran npm install to check if it was something to do with any of my dependencies (before your last response).
The netlify build still showed the error in the console.
So I ran npm install gatsby-module-loader just for kicks, and built it again. Manual deploy to netlify shows a 100% functional site now. 馃
https://rollcalldocs.netlify.com/
Also, I just ran a search on my dev folder and the only references to /Users/joshweaver/Documents/... are in internal gatsby api files.
Perhaps you checked in .cache
(Back to my personal account -- Still at the office)
Double-checked that just now.
# Project dependencies
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
.cache/
# Build directory
public/
.DS_Store
yarn-error.log
Not sure if these issues are related but I just saw someone else reported gatsby-module-loader reference issue here: #2358
Knowing gatsby-module-loader is a direct dependency of gatsby... I just uninstalled and reinstalled gatsby .... again... And it resolved this.
npm uninstall gatsby and then npm install gatsby worked for me
Most helpful comment
npm uninstall gatsbyand thennpm install gatsbyworked for me