inxilpro / node-app-root-path

Determine the root path to your project
MIT License
605 stars 29 forks source link

app-root-path is using "module" node module which cause issue when using at client side #13

Closed dilipkumar2k6 closed 8 years ago

dilipkumar2k6 commented 8 years ago

I am using Angularjs 1.x and commonjs and compiling using webpack. Since my compiled js file serve on browser therefore it has to be as small as possible. I thought to use app-root-path module for my client side as well however i realized that it throws error in webpack compilation because "resolve.js" is doing require("module"). And when I installed "module" node package then it included big files and also throws error in browser console.

I am not expecting to solve this issue. However wanted to share that due to this issue i can't use it for client side module bundling.

inxilpro commented 8 years ago

Yep, this module is not meant to work on the client side.

rudeluv commented 8 years ago

I'm also using Browserify mostly just to pack modules for a CLI tool I'm working on.

I found a workaround after digging through an issue and a blame.

Here's how I was able to get it to compile, although I think I'll just fork it and remove the electron support.

  1. npm install --save-dev electron-prebuilt 2.. Modify resolve.js remote require to var remote = require('electron-prebuilt').remote;

After doing this I could successfully pack my build. Hope it helps.

inxilpro commented 8 years ago

I believe you can also just tell browserify to ignore the module module. Since that chunk of code will never get hit, it should be fine.

rudeluv commented 8 years ago

That makes a lot of sense. Thanks!