Skip to content
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

Error in webpack #64

Closed
Regaddi opened this issue Jul 13, 2017 · 6 comments
Closed

Error in webpack #64

Regaddi opened this issue Jul 13, 2017 · 6 comments

Comments

@Regaddi
Copy link

Regaddi commented Jul 13, 2017

Hi,

when trying to require ical-generator via const ical = require('ical-generator'); webpack throws the following error:

ERROR in ./~/ical-generator/lib/calendar.js
Module not found: Error: Can't resolve 'fs' in '/my-project/node_modules/ical-generator/lib'
 @ ./~/ical-generator/lib/calendar.js 411:8-21 425:15-28
 @ ./~/ical-generator/lib/index.js
 ...

Can't get it up and running 😢

@Regaddi
Copy link
Author

Regaddi commented Jul 13, 2017

Nevermind. It was totally webpack related and had nothing to do with your package 😄

@Regaddi Regaddi closed this as completed Jul 13, 2017
@rally25rs
Copy link

rally25rs commented Nov 15, 2017

@Regaddi do you remember what you did to "fix" this? Did you just have webpack ignore the fs package?


Edit:

For anyone else who ends up here, you need to add to your Webpack config:

  node: {
    fs: 'empty'
  },

ical-generator only uses the fs module to save the ical file to the filesystem, so as long as you don't call .save() it will work fine in a web environment.

@sebbo2002
Copy link
Owner

@rally25rs I'll add this to the docs later, thank you!

@sebbo2002 sebbo2002 mentioned this issue Nov 20, 2017
39 tasks
@CoffeyMachine
Copy link

This solution worked for me with Angular 8 (without Ivy)
https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d

@djplaner
Copy link

Seems recent updates to webpack break the previous solution. The error I was seeing

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.node has an unknown property 'fs'. These properties are valid:
   object { __dirname?, __filename?, global? }
   -> Options object for node compatibility features.

The solution that worked for me is from StackOverflow. Add the following to webpack configuration

resolve: {
  fallback: {
    fs: false
  }
}

@sebbo2002
Copy link
Owner

@djplaner Thanks for your note, I updated the readme in ee2cb70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants