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: Can't resolve 'fs' #121

Open
NickRimer03 opened this issue Apr 5, 2019 · 3 comments
Open

Error: Can't resolve 'fs' #121

NickRimer03 opened this issue Apr 5, 2019 · 3 comments

Comments

@NickRimer03
Copy link

Hello there!

First of all thank you very much for droids library I've spend a lot of time to looking for. Now it's freaking easy to compile my sass scripts while code is running in browser.
It seems to work fine at all (there I mean that code works and compiles like expected) except one little thing. An error appers while using webpack.

The error:

ERROR in ./node_modules/sass.js/dist/sass.sync.js
Module not found: Error: Can't resolve 'fs' in 'C:\Projects\nr-fontface\node_modules\sass.js\dist'
 @ ./node_modules/sass.js/dist/sass.sync.js 62:1108-1121 62:382030-382043
 @ ./src/index.js

I'm confused but that error really doesn't prevent my code from working and compiling.
Further I've found the solution to add this to my webpack.config.js:

node: {
  fs: "empty"
}

Is it really a total solution or you can recommend smth. more elegant?

The way I'm using your lib for now:

import sass from "sass.js";
sass.compile(sassString, result => {});
@rodneyrehm
Copy link
Member

fs comes from emscripten. I have not used sass.js in a webpack environment, only loaded it in the browser as static asset - I have no idea why webpack is complaining here, to be honest.

Is it really a total solution or you can recommend smth. more elegant?

I'd have probably done the same thing.

@hason
Copy link

hason commented Feb 10, 2020

@rodneyrehm You should add -s ENVIRONMENT="web" to build line for sass.sync.js and -s ENVIRONMENT="worker" for sass.worker.js. See https://gist.github.com/surma/b2705b6cca29357ebea1c9e6e15684cc#gistcomment-2771604. Can you tag a new version?

@rodneyrehm
Copy link
Member

@hason building sass.js with -s ENVIRONMENT="web" seems to break use in node - at leas the tests fail completely:

Running "mochaTest:src" (mochaTest) task
>> Mocha exploded!
>> ReferenceError: document is not defined

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

3 participants