tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.41k stars 640 forks source link

cannot resolve module 'fs' #545

Open roopakpv opened 7 years ago

roopakpv commented 7 years ago

i am using latest edgejs(6.5.1) in my node project. but when i use edge in my project,

var edge = require('edge');

i am getting this error "cannot resolve module 'fs' " later when i checked the edge.js file i see that edge is using 'fs'

var fs = require('fs') , path = require('path') , builtEdge = path.resolve(dirname, '../build/Release/' + (process.env.EDGE_USE_CORECLR || !fs.existsSync(path.resolve(dirname, '../build/Release/edge_nativeclr.node')) ? 'edge_coreclr.node' : 'edge_nativeclr.node')) , edge;

How can i fix this error?

agracio commented 7 years ago

Have you tried using fs without edge in your project? Does it resolve correctly?

roopakpv commented 7 years ago

i am not using fs module in my project. But edge is using it internally.

Like agracio suggested i removed edge and tried using fs and i am getting the same error.

agracio commented 7 years ago

Just a guess, but is it a web project you running in browser? Or perhaps you are using webpack/browserify?

roopakpv commented 7 years ago

i am having a nodejs project in which we are using webpack

agracio commented 7 years ago

If the project is not for web/browser add

target:'node'

to your webpack config. You will be able to access full nodejs stack.

roopakpv commented 7 years ago

Ours is a web project. i tried adding target:'node' and the console is again showing the fs error

agracio commented 7 years ago

You will not be able to use edge in a web project, same as you cannot access most of clients PC resources in a browser.