Gmousse / dataframe-js

No Maintenance Intended
https://gmousse.gitbooks.io/dataframe-js/
MIT License
460 stars 38 forks source link

module not found #64

Closed kishor-dabi closed 5 years ago

kishor-dabi commented 6 years ago

when using dataframe-js it give warning:

WARNING in ./node_modules/dataframe-js/lib/reusables.js Module not found: Error: Can't resolve 'fs' in '/home/kishoredabi/Desktop/inv_master/core-web-inventory/core-web/node_modules/dataframe-js/lib'

Gmousse commented 6 years ago

Hi @kishor-dabi, Thanks for using dataframe-js. This warning occurs when you try to write a file when you are in the browser (where the module fs doesn't exist). However the warning message seems wrong.

Can you give more informations about your usage ?

kishor-dabi commented 6 years ago

@Gmousse Thanks for reply, I am Using dataframe-js in angular 6. I have install dataframe-js using npm. "npm i dataframe-js"

but it give warning at compile time and build time

WARNING in ./node_modules/dataframe-js/lib/reusables.js Module not found: Error: Can't resolve 'fs' in '/home/kishoredabi/Desktop/inv_master/core-web-inventory/core-web/node_modules/dataframe-js/lib'

The version of datafrane-js and other is: node : 8.11, dataframe-js: ^1.3.2, anlgular-cli: 6.1.3

maihannijat commented 5 years ago

I have the same warning while compile. I do not write file at all.

Gmousse commented 5 years ago

hi @maihannijat, I m currently modifying the library build. It's possible that the new release can fix this. Can you test with the branch feature/upgrade-babel ?

Thank you

maihannijat commented 5 years ago

Steps taken: 1- Removed dataframe-js directory from node_modules 2- Installed with npm install git+https://github.com/Gmousse/dataframe-js.git#feature/upgrade-babel 3- Run the development environment

Result:

WARNING in ./node_modules/dataframe-js/lib/reusables.js Module not found: Error: Can't resolve 'fs' in '/Users/mnijat/Desktop/oneplatform/frontend/node_modules/dataframe-js/lib'

Confirmation: I have the following in package.json: "dataframe-js": "git+https://github.com/Gmousse/dataframe-js.git#feature/upgrade-babel",

Gmousse commented 5 years ago

Ok strange... I will continue to look for a solution .

Gmousse commented 5 years ago

After looking a bit, it s related to webpack (or similar) which resolves the require fs at build time and fails even if the require has a try catch block.

Can you try to add:

In your webpack config:

node: {
    fs: "empty"
}

Or if you can t, in your package.json:

"browser": {
    "fs": false
}

If it works I will see if I can add it in the library s package.json.

maihannijat commented 5 years ago

Tried the following and it did not help:

"browser": {
    "fs": false
}
Gmousse commented 5 years ago

Ok. Can you give me your webpack, node versions, and your webpack config (if possible) to reproduce this error. Indeed, on my side I can build with rollup or webpack without errors.

maihannijat commented 5 years ago

Node version: v10.9.0 I am using with the following project: https://github.com/akveo/ngx-admin

You will get the error if you clone and add the package there.

Gmousse commented 5 years ago

After a quick investigation, it seems its related to angular: https://github.com/angular/angular-cli/issues/10681

Indeed, the require is clearly try catched in dataframe-js and should work anyway. It's related to how angular build its bundle.

It seems adding

"browser": {
    "fs": false
}

in the library package.json resolves your issue (I have no longer warning with your repository). Could you try to reinstall "dataframe-js": "git+https://github.com/Gmousse/dataframe-js.git#feature/upgrade-babel", and retry ?

maihannijat commented 5 years ago

The error is gone with above instructions but it broke my project. I get the following error in the browser console and the project does not load:

ERROR Error: "Uncaught (in promise): ReferenceError: global is not defined

I removed the package and installed the stable version and the project is running but with same warning.

Gmousse commented 5 years ago

Sorry ! js environment can be a torment sometimes.

I will continue to work on it. Stay tuned.

@maihannijat it's a bit strange. I have cloned your repo, use my upgrade-babel branch and it seems to work (without displaying the warning anymore). I don't understand.

Gmousse commented 5 years ago

Hi @maihannijat

My feature was merged with the develop branch. It works with your project (without the warning). Feel free to test the develop branch (it can be cool to have feedbacks).

I will close the issue after the release 1.4.0 (in a week).

bluehazetech commented 5 years ago

Any ETA on when 1.4.0 will be released with this fix?

Gmousse commented 5 years ago

Hi ! I will try to work on the library to release the 1.4.0 asap. This week I hope. Could you try the develop branch ? The fix is merged.

Gmousse commented 5 years ago

@bluehazetech I m working to deliver the 1.4.0 as soon as possible. Feel free to test the develop branch via #72