-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
node options flag not recognized using gulp and browserify #1472
Comments
I believe
In this case, I think you are just interested in
|
i will give that a try. |
So, tried that. But now seeing the below error: module.js:338
throw err;
^
Error: Cannot find module '_process'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at s (/vagrant/development/app/dist/server.js:1:176)
at /vagrant/development/app/dist/server.js:1:367
at Object../Configuration (/vagrant/development/app/dist/server.js:4930:14)
at s (/vagrant/development/app/dist/server.js:1:316)
at e (/vagrant/development/app/dist/server.js:1:487)
at Object.<anonymous> (/vagrant/development/app/dist/server.js:1:505) Here is my gulp task: import browserify from 'browserify';
import buffer from 'vinyl-buffer';
import gulp from 'gulp';
import source from 'vinyl-source-stream';
gulp.task('scripts:server', () => {
const bundler = browserify(
'build/source/server.js',
{
builtins: false,
debug: true,
}
);
const bundlerError = (err) => {
console.error(err);
};
return bundler.bundle()
.on('error', bundlerError)
.pipe(source('server.js'))
.pipe(buffer())
.pipe(gulp.dest('dist'));
}); Here is the offending code snippet (wrapped offending line with >>>> <<<<): ...
// Catch 404
app.use(function (req, res) {
log.info(req.originalUrl);
var err = new Error('404 - Not Found');
err.status = 404;
log.info(err);
res.status(404);
res.render('404', {
title: 'MovieSeriesRankings.com - Page Not Found'
});
});
app.listen(config.nodePort);
>>> }).call(this,require('_process'),"/build/source") <<<<
},{"./Configuration":23,"./router":28,"_process":undefined,"babel-polyfill":31,"body-parser":33,"bunyan":84,"express":273,"path":undefined,"serve-favicon":567}],30:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
... No idea what |
That would be browserify's attempt to resolve the process variable, which you presumably are using in that file. Doing If
|
Yep - that did it. Thanks a lot. So - for the historical record, this solutions seems like a workaround for what I am able to accomplish with the CLI command:
However, following the above steps have provided the same results, so for the time being it doesn't feel like like the |
Through the api the parameters necessary to replicate
That's how my gulp task looks like:
Hope this helps someone. |
@tlopo I'll give this a try |
This issue should not be closed, the |
Reopening this issue since it sounds like @EvanCarroll knows of a solution. |
@stevus all of the issues on #1570 are essentially the same, they arise from a confusion and dissonance between the CLI Options, and the Browserify(file,Options) In this case,
(and all other node builtins), which is ultimately the line that solves the problem with
Subscribe to that issue if you want to see this resolved. I'm only writing the code if someone with commit access gives me the thumbs up. There are too many uncommited patches in this project as is. |
+1 @tlopo |
I faced the same issue using browserify to bundle my javascript modules in an Electron app. ignoreMissing: true,
builtins: false,
commondir: false,
browserField: false,
detectGlobals: false |
@tanguy2m And did those settings fix the problem? I'm also running into this issue when using browserify and parcel :/ parcel-bundler/parcel#725 |
I concur with @tanguy2m thanks to him, he has saved me HOURS of debugging... Thanks mate 🗡
gulpfile.js
I know this is not specific for electron question, but considering I found my solution here I felt like it was a nice decision in case someone needed to find a solution. |
Browserify shims the core
http
module withstream-http
for browser compatibility, and has a--node
flag to prevent this from happening. However, I am unable to do this through gulp, or the documentation does not explain how. I would like to perform the following and not have thestream-http
module included in my final browserify bundle:I can see the
bare: true
andbrowserField: false
do something if I pass them into browserify as options, however,node: true
seems to have no effect.If I run browserify as a command and not through gulp, it works just fine:
The text was updated successfully, but these errors were encountered: