-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot resolve module 'fs' #449
Comments
@najamkhn, just in case, are you trying to build a web-client app (= to be running in the browser) using LokiJS with the webpack / babel toolchain (or alike)? |
Yes using it with webpack and building web app. |
@najamkhn Okay, that's what I suspected, based on the specific issue that you reported. But I needed to double-check my guess with you first. What you need to do is, to add the following configuration section and parameters into your webpack.config.js file: node: { fs: 'empty' } |
@najamkhn Also, depending on your specific configuration and other modules that you use in your web app, you may need to extend that section above to something like: node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
'crypto': 'empty'
}, |
@najamkhn Finally, in the case if you need a piece of Webpack's official documentation on that part, you can refer to: https://webpack.github.io/docs/configuration.html#node |
will you extract it outside ? |
@jetiny, extract what? I am not sure if I understand your question. Please, elaborate. |
Thanks to all who answered, I believe this is resolved. In future releases we may extract the (node) filesystem adapter out into its own module. |
For what it's worth, I was having this problem with Angular 5 and Angular CLI 1.5.0 when running unit tests, but not when doing a regular build / serve. While the webpack.config that angular cli was using already had webpack: {
node: {
fs: 'empty'
}
} The nice thing about this problem / solution was that it doesn't require having to |
Would someone give me some guidance as to how to fix the configuration in Rollup instead of Webpack? I also get the
at the root of the default exported object of the EDIT: Finally found it! I had to install import commonjs from "@rollup/plugin-commonjs";
import globals from "rollup-plugin-node-globals";
import builtins from "rollup-plugin-node-builtins";
export default {
input: "src/main.js",
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/build/bundle.js",
},
plugins: [
commonjs(),
globals(),
builtins(),
}; |
Thanks @davidsavoie1 Big time-saver, I was going to give up. I wished LokiJs would be more browser-friendly out of the box, or have a lokijs-browser. Anyway, the functionalities look to be what I am looking for. |
I'm not sure why but I've been getting it everytime when I install loki from npm install and initialise it with the following lines:
The text was updated successfully, but these errors were encountered: