Reputation: 4207
I am trying to browserify my module. I have a dependency on this https://www.npmjs.com/package/chilkat_win32 It is there in my node_modules folder and this is how the structure of it looks.
As you can see, there is no js class. But there is a .node file. When I run browserify on my module I get the following error.
SyntaxError: Unexpected character '�' (2:2) while parsing G:\Projects\Kube 2.0\edge-node-sdk-typescript\edge-node-sdk-js\node_modules\chilkat_win32\chilkat.node while parsing file: G:\Projects\Kube 2.0\edge-node-sdk-typescript\edge-node-sdk-js\node_modules\chilkat_win32\chilkat.node
at DestroyableTransform.end [as _flush] (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\insert-module-globals\index.js:96:21)
at DestroyableTransform.<anonymous> (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:115:49)
at DestroyableTransform.g (events.js:260:16)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at prefinish (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:465:12)
at finishMaybe (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:473:7)
at endWritable (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:485:3)
at DestroyableTransform.Writable.end (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:455:41)
at DestroyableTransform.onend (C:\Users\macilamanym\AppData\Roaming\npm\node_modules\browserify\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:495:10)
Is this because the .node file cannot be read or browserified? If so, how can I cope up with this module and browserify my module? Please advice.
Below is the gulp browserify task.
gulp.task('browserify', function() {
// Single entry point to browserify
gulp.src('lib/main/EdgeNodeBrowserify.js')
.pipe(browserify({
standalone: 'EdgeNode'
}))
.pipe(rename('browserEdgeNode.js'))
.pipe(gulp.dest('./build/js'))
});
Upvotes: 2
Views: 506
Reputation: 9330
It's actually an addon which usually used to provide interface between JavaScript running in nodejs and underlying C/C++ libraries. The file is a binary file produced by a build step. In node.js those addons can be included with require
though they cannot be browserified since it makes no sense.
I'm not sure why do you need such C/C++ bindings in browser side. One way is to ignore such module when bundle
// assuming you use gulp-browserify
// please be advised not to use that since it's no longer being maintained
.pipe(browserify({
ignore : ['chilkat_win32']
}))
Upvotes: 3