You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added this package to Gatsby.js React project.
when running "gatsby develop" CLI, site works fine. script loads in what is needed.
But when trying to create production build, "gatsby build" the build fails because scriptjs tries to execute since it thinks it is in browse environment meanwhile it is not yet. The link below explain the situation better. So if you can update your code to only run when "document" is available would be great.
In the meantime I am using method b) by placing the code in componentDidMount(), which is working for me.
I added this package to Gatsby.js React project.
when running "gatsby develop" CLI, site works fine. script loads in what is needed.
But when trying to create production build, "gatsby build" the build fails because scriptjs tries to execute since it thinks it is in browse environment meanwhile it is not yet. The link below explain the situation better. So if you can update your code to only run when "document" is available would be great.
In the meantime I am using method b) by placing the code in componentDidMount(), which is working for me.
See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
10 | else this[name] = definition()
11 | })('$script', function () {
WebpackError: document is not defined
script.js:12
~/scriptjs/dist/script.js:12:1
script.js:8 doc
~/scriptjs/dist/script.js:8:1
script.js:11 Object.module.exports.layoutContext
~/scriptjs/dist/script.js:11:2
index.js:5 Object.module.exports.siteMetadata.title
src/layouts/index.js:5:1
index.js:3 Object.exports.__esModule
.cache/layouts/index.js:3:3
sync-requires.js:6 Object.exports.__esModule
.cache/sync-requires.js:6:35
The text was updated successfully, but these errors were encountered: