question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use fcl-js with gatsby

See original GitHub issue

Steps to reproduce (create a stock gatsby app and add fcl dependencies):

  • install gatsby globally npm install -g gatsby
  • follow command line prompts, any choices from the prompt are fine
  • cd to created project and run npm install
  • create new gatsby project npm init gatsby
  • add fcl dependencies npm install --save @onflow/fcl @onflow/types
  • start server npm run develop
  • there’s an error seen at http://localhost:8000/

Error seen in terminal:

 ERROR #98123  WEBPACK

Generating development JavaScript bundle failed


/Users/aniket/projects/learning/gatsby-fcl/src/pages/index.js
  20:18  error  'pageStyles' is not defined  no-undef

✖ 2 problems (1 error, 1 warning)


failed Re-building development bundle - 1.320s
ERROR in ./node_modules/@improbable-eng/grpc-web-node-http-transport/lib/index.js 4:11-26
Module not found: Error: Can't resolve 'http' in '/Users/aniket/projects/learning/gatsby-fcl/node_modules/@improbable-eng/grpc-web-node-http-transport/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
	- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "http": false }
 @ ./node_modules/@onflow/sdk/dist/sdk.module.js 1:864-945 1:11380-11381
 @ ./node_modules/@onflow/fcl/dist/fcl.module.js 1:0-30 1:30-254 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714
1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714 1:254-714
1:254-714 1:254-714 1:254-714 1:1314-1315 1:1768-1769 1:2019-2024 1:2255-2267 1:2535-2541 1:2543-2551 1:2563-2569 1:2620-2627 1:2644-2652 1:25335-25336 1:27174-27181 1:27267-27272 1:27344-27351 1:27620-27625 1:29365-29370 1:30130-30137
1:30922-30929 1:31165-31172 1:32825-32826 1:32828-32829 1:32840-32841 1:34719-34731 1:35015-35023 1:35087-35093 1:35095-35108 1:35120-35126 1:35163-35170 1:35180-35190 1:35215-35222 1:35244-35260 1:35300-35308 1:35515-35522 1:35550-35551
1:35652-35653 1:35727-35728 1:35729-35730 1:35891-35892 1:36183-36184 1:36328-36329 1:36388-36389 1:36391-36392 1:36430-36431 1:37246-37251 1:37391-37396 1:40092-40093
 @ ./src/pages/index.js 9:0-37 10:0-35 11:0-6 29:11-36
 @ ./.cache/_this_is_virtual_fs_path_/$virtual/async-requires.js 16:11-18:5
 @ ./.cache/app.js 16:0-52 29:87-33:1 32:29-42 35:27-40 29:0-33:2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
neelkamal0666commented, Mar 10, 2022

Thanks @10thfloor. It worked for me. I added gatsby-node.js in the root directory of my project. Installed node-polyfill-webpack-plugin (npm install node-polyfill-webpack-plugin).

Then added this in gatsby-node.js `const NodePolyfillPlugin = require(“node-polyfill-webpack-plugin”)

module.exports = { // Other rules… plugins: [ new NodePolyfillPlugin() ] }`

There are other approach as well as mentioned in this article :https://namespaceit.com/blog/how-fix-breaking-change-webpack-5-used-to-include-polyfills-for-nodejs-core-modules-by-default-error

1reaction
chaseflemingcommented, Mar 9, 2022

Thanks for adding the link @10thfloor . It’s a top priority and in active development. @anikets you can track progress on this issue here: https://github.com/onflow/fcl-js/issues/982

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Common Errors - Gatsby
Errors using gatsby-plugin-image and sharp. Field "image" must not have a selection since type "String" has no subfields; Problems installing sharp with ...
Read more >
Error when running gatsby commands #33723 - GitHub
When I run the gatsby build or the gatsby develop, errors arrives. ... Workaround: Invoke node manually and instruct it to use the...
Read more >
Can't access gatsby environment variables on the client side
A few steps & notes that should solve your problem: console.log(process.env) will always print empty object. To see if it's really working, ...
Read more >
How to Install, Setup, Build and Deploy Gatsby JS ... - YouTube
While I can't say I know what walking on the moon feels like, I can tell you that I am now comfortable using...
Read more >
unable to install Gatsby on macbook : r/gatsbyjs - Reddit
You're trying to install a package globally. You need to use sudo. sudo npm install -g gatsby-cli.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found