Closed trumanjchan closed 8 months ago
Hello, @trumanjchan. This error is expected because the implementation for fs
is null
by default. You can use a package such as memfs
(or something else depending on your needs) along with the overrides
config option to polyfill fs
. See https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/43 for more info (this is a duplicate of that issue).
Hi! I read I should post this in Discussions but I couldn't find the tab, sorry!
I have this error, so I did
bun install -D vite-plugin-node-polyfill
and thought that would importfs
correctly. I'm still getting this issue where my Nuxtjs3 web app, upon refreshing the page, shows a brief flash of everything being loaded then showing the 500: Cannot read properties of null (reading '__esModule') error pointing at theimport fs from 'fs'
line.I'm not sure if I imported the plugin correctly into my
nuxt.config.ts
file. I also currently don't have a /plugins directory. I'm using node v18.0.0 and bun as my package manager.Any help or ideas is much appreciated! Thank you!
Currently with
import fs from 'fs'
:If I change the import line to
import * as fs from 'fs'
:If I change the import line to
const fs = require('fs')
: