Browserify with paths to folders in my system

Vinz243 picture Vinz243 · Feb 24, 2014 · Viewed 10.4k times · Source

When I compile markdown-symbols using Browserify 3.30.2 (browserify file.js -o bundle.js), I get something like that :

!function(e){if("object"==typeof exports...[function(_dereq_,module,exports){

},{}],2:[function(_dereq_,module,exports){
...
...
[on line 8000] 
    : function (str, start, len) {
        if (start < 0) start = str.length + start;
        return str.substr(start, len);
    }
;

}).call(this,_dereq_("C:\\Users\\Me\\AppData\\Roaming\\npm\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js"))
},{"C:\\Users\\Me\\AppData\\Roaming\\npm\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js":11}],14:[function(_dereq_,module,exports){
module.exports=_dereq_(3)
},{}],15:[function(_dereq_,module,exports){
module.exports=_dereq_(4)
},{"./support/isBuffer":14,"C:\\Users\\ME\\AppData\\Roaming\\npm\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js":11,"inherits":10}],16:[function(_dereq_,module,exports){
var frep = _dereq_('frep');
var file = _dereq_('fs-utils');
var delims = _dereq_('delims');
var _ = _dereq_('lodash');
...

As you can see, there are absolute paths to my files here. Why ? How can I remove them ?

EDIT: here is my build.js file

 var browserify = require('browserify-middleware')
fs = require('fs');
var b = browserify('./index.js', {
    'opts.basedir': './'
});
b({
    // Mocks up express req and res
    headers: []
}, {
    getHeader: function () {},
    setHeader: function () {},
    send: function (a) {
        console.log('send', a);
    },
    end: function (a) {
        //console.log('end', a.constructor.name);
        //  fs.write('bundle.js', a, undefined, undefined, function (err) {
        console.log(a.toString());
        //});
        //  a.pipe(fs.createWriteStream('bundle.js'));
    },

});

And to run node build > bundle.js. same problem. If I replace basedir value by for instancee ihatebrowserify there is an error about something not resolved.

Answer

Song Gao picture Song Gao · Oct 10, 2014

This came across to me as well today. It turns out there's a boolean option --full-path[0] now that solves the problem.

For example:

browserify -o bundle.js --full-path=false index.js

[0] https://github.com/substack/node-browserify/blob/master/bin/args.js