neutrino
neutrino copied to clipboard
Error: Can't resolve 'fs' in '...\source-map-support'
- What version of Neutrino are you using? ^9.3.0
- Are you trying to use any presets? If so, which ones, and what versions? "@neutrinojs/react-components": "^9.3.0"
- Are you using the Yarn client or the npm client? What version? Yarn 1.22.4
- What version of Node.js are you using? v12.16.1
- What operating system are you using? Windows 10
- What did you do? Created a component library and imported it into a Gatsby app.
- What did you expect to happen? No errors would come up.
- What actually happened, contrary to your expectations? My Gatsby app builds and runs fine, but during build I see a warning that says
Error: Can't resolve 'fs' in '...\source-map-support'
. I tried googling this error and trying to make it go away by settingtarget: "node"
andnode: {fs: 'empty'}
in my neutrinorc and then building/importing into my Gatsby app, but that didn't get rid of the error.
@ROODAY Hi! If the output of the build is to be used in a Gatsby project, you'll want to be using target: "web"
, not target: "node"
. Web is the default, so you can remove the target specification entirely.
Failing that, please could you provide a reduced testcase that demonstrates the problem? :-)
@edmorley I meant that I had tried target: "node"
as an attempted fix (the issue appeared with the default settings first). Here's a minimal reproduction of the issue:
-
I made a zip that contains gatsby starter default and a default neutrino react components project with source map support. You can get the zip here.
-
Run
yarn install
in both the gatsby starter and the neutrino project. -
Run
yarn build
in the neutrino project. -
Create a folder called
test
in the node_modules directory of the gatsby project. -
Copy the contents of the neutrino
build
directory into thetest
node module directory. -
Run
yarn develop
in the gatsby starter and you'll get the warning:
warn Module not found: Error: Can't resolve 'fs' in '...\repro\gatsby-starter-default\node_modules\source-map-support'
The error isn't huge as gatsby only recognizes it as a warning and in practice I haven't had any issue with the app itself but I'm trying to get rid of all warnings/errors in my project just in case it ends up being an issue later.