Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Getting "Uncaught TypeError: Cannot set property 'query' of undefined" on Netlify #136

Open
julians300 opened this issue Jan 26, 2020 · 2 comments

Comments

@julians300
Copy link

My project works fine locally but when deploying to netlify I am getting js errors.

I followed this guide:
https://prismic.io/docs/reactjs/getting-started/prismic-gatsby

Here is the repo:
https://github.com/julians300/gatsby-test

Here is the project deployed to Netlify:
https://naughty-golick-713de1.netlify.com/

Any help getting Prismic to work with Netlify would be appreciated!

@sebastiansson
Copy link
Contributor

sebastiansson commented Jan 29, 2020

@julians300 Did you find a solution? Facing the same issue.

I have tried using the 3.4.0-beta.2 but that causes another error in my /templates files:

warn The GraphQL query in the non-page component ".../src/templates/page.js" will not be run.
Exported queries are only executed for Page components. It's possible you're
trying to create pages in your gatsby-node.js and that's failing for some
reason.

Template file page.js:

import React from 'react'
import { graphql } from 'gatsby'

const Page = ({ data }) => {
	console.log(data)
	return <div>Test</div>
}

export const query = graphql`
	query($uid: String!, $lang: String!) {
		prismic {
			content(uid: $uid, lang: $lang) {
				title
				body {
					... on PRISMIC_ContentBodyTest {
						type
						label
						primary {
							test_title
						}
					}
				}
			}
		}
	}
`

export default Page

gatsby-config.js

{
    resolve: 'gatsby-source-prismic-graphql',
    options: {
        repositoryName: 'test', // required
        defaultLang: 'sv-se', // optional, but recommended
        langs: ['sv-se', 'no'],
        previews: true,
        pages: [
            {
                type: 'Content',
                match: '/:lang?/:uid',
                path: '/', // placeholder page for unpublished documents
                component: require.resolve('./src/templates/page.js'),
                langs: ['se-sv', 'no'],
            },
        ],
    },
},

3.4.0 seems to be released on Github but is not available on Npm. Why is that @birkir?

EDIT: Got it working somehow, renamed page.js to content.js and it seemed to work. Probably something else...

@birkir
Copy link
Owner

birkir commented Jan 29, 2020

It was tagged incorrectly, its available through @canary as usually.

So 3.4.1-alpha.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants