Hi,
Getting a warning while creating executeable
Warning Failed to make bytecode node8-x64 for file /snapshot/node_modules/brotli/build/encode.js
Try to run pkg with the --debug flag, for more information.
Hi sven,
Got this error when run with --debug flag.brotli npm package is using emscripten c++ compiler to compile c++ code to javascript directly.the encode.js file is generated by emscripten c++ compiler and this file is minified one.Many well known packages like fontkit is using brotli package internally for compression.this pkg is having more than 2 lakh downloads mainly as dependency of other packages.
Will get same error if try to generate binary for fontkit.
Warning Failed to make bytecode node8-x64 for file C:\snapshot\SI-Server\node_modules\brotli\build\encode.js
same
I'm running into this with Yoga, the Facebook Flexbox cross-environment implementation.
I have the same error, has anybody got a workaround ?
Warning Failed to make bytecode node12-x64 for file C:\snapshot\<projectName>\node_modules\brotli\build\encode.js
I'm getting this issue as well
> Warning Failed to make bytecode node12-x64 for file /snapshot/<project-name>/node_modules/brotli/build/encode.js
Hi @emaxedon @Jozsan @benfletcher @alexluoli
How did you fix it? Did you find a workaround?
Thanks
Personally, I removed the dependencies that used brotli
Thanks @Jozsan for your answer
Won't be possible for me. Need to find another solution..
brotliwas the only one failing? Did you know (even after) the difference with the other modules justifying all this mess up?
For me, the same is happening with a dependency called ky. Not depending on it directly. It seems like it requires either transpilation or Node's experimental module support, because it seems to depend on ES2015's module syntax/system.
I bundle a single index.js file from TypeScript sources using Parcel (with parcel build src/index.ts --target node --out-dir dist/main --out-file index.js --experimental-scope-hoisting).
Targets:
It seems like running pkg using package.json-based settings as e.g. pkg . --out-dir dist/exe/ causes this error, somehow.
My pkg config in package.json is as follows:
{
"pkg": {
"targets": [
"node12-linux-x64",
"node12-win-x64"
]
}
}
Here are the last lines of output from the second command (i.e. pkg . --debug):
[
{
"nodeRange": "node12",
"platform": "linux",
"arch": "x64",
"output": "~/<REDACTED>/<REDACTED>/dist/exe-linux",
"forceBuild": false,
"fabricator": {
"nodeRange": "node12",
"platform": "linux",
"arch": "x64",
"forceBuild": false,
"binaryPath": "~/.pkg-cache/v2.6/fetched-v12.13.1-linux-x64"
},
"binaryPath": "~/.pkg-cache/v2.6/fetched-v12.13.1-linux-x64"
},
{
"nodeRange": "node12",
"platform": "win",
"arch": "x64",
"output": "~/<REDACTED>/dist/exe-win.exe",
"forceBuild": false,
"fabricator": {
"nodeRange": "node12",
"platform": "linux",
"arch": "x64",
"forceBuild": false,
"binaryPath": "~/.pkg-cache/v2.6/fetched-v12.13.1-linux-x64"
},
"binaryPath": "~/.pkg-cache/v2.6/fetched-v12.13.1-win-x64"
}
]
/snapshot/<REDACTED>/node_modules/ky/index.js:460
export default createInstance();
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:85:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)
/snapshot/<REDACTED>/node_modules/ky/index.js:460
export default createInstance();
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:85:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)
> Warning Failed to make bytecode node12-x64 for file /snapshot/<REDACTED>/node_modules/ky/index.js
C:\snapshot\<REDACTED>\node_modules\ky\index.js:460
export default createInstance();
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:85:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)
C:\snapshot\<REDACTED>\node_modules\ky\index.js:460
export default createInstance();
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:85:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)
> Warning Failed to make bytecode node12-x64 for file C:\snapshot\<REDACTED>\node_modules\ky\index.js
Surprisingly, if I run pkg dist/main/index.js --output dist/exe/<REDACTED> --targets node12-linux-x64,node12-win-x64 instead, this bytecode generation failure does not occur.
I have run into the same problem:
> Warning Failed to make bytecode node12-x64 for file /snapshot/<project-name>/node_modules/brotli/build/encode.js
However, I was able to compile the same project using nexe. Not much of help for solving the issue at hand, I know. But I thought I'd let you know.
What I'm going to write is very weird. I was able to find the part that was causing this by very ugly reverse engineering:
In node_modules/brotli/build/encode.js, go to line 40 and search for function Cb. It should be the last one. It ends with the following part: return g|0. When I replaced this with a simple assignment & return, it stopped the error happening (e.g.: const abcd = g|0; return abcd).
I just hopped on this problem so bear in mind the following:
encode.js is platform dependent so this solution might be completely bad for you (I use debian linux with node v10.16.0)Does you application work after Failed to make bytecode? Because it is intended as Warning - it still lets the application execute well in most cases.
@SLOBYYYY said:
In
node_modules/brotli/build/encode.js, go to line 40 and search forfunction Cb. It should be the last one. It ends with the following part:return g|0. When I replaced this with a simple assignment & return, it stopped the error happening (e.g.:const abcd = g|0; return abcd).
I've no idea how you found that, but I just tried the same thing and the warning has disappeared for me too. No idea why and I agree that it might be just hiding the message rather than solving anything.
In answer to the question from @igorklopov, my application seems to work fine after the warning occurs. Does this mean it's not a problem?
Does wrapping in parens return (g|0) also resolve the problem?
Is there a strategy you can recommend to resolve these issues with other culprit files @SLOBYYYY ? Thanks!
Does you application work after Failed to make bytecode? Because it is intended as Warning - it still lets the application execute well in most cases.
You won't like my answer: I don't know. I just jumped deep into this problem when other team members were busy with shipping new features, while trying to solve packaging and integrate this into the CI and also to make it deployable.
I found this "solution" but I didn't do a follow-up whether or not it actually made any difference.
Is there a strategy you can recommend to resolve these issues with other culprit files @SLOBYYYY ? Thanks!
If you read my previous paragraph, this heavily depends on whether or not it matters at all. If it does, an ugly-but-working method would be sed-ing this part in your CI script. Calling this a "strategy" would be an overstatement though :)
In any case, I'm very interested finding the "why" of this problem too.
Faced the same issue after upgrading pkg to version 4.4.9.
Downgrated to 4.3.7 back and issue dissapeared. The only problem is that the 4.3.7 does not supports node12 but for me it doesnt matter.
Also I'm using node 8.9.0.
Most helpful comment
What I'm going to write is very weird. I was able to find the part that was causing this by very ugly reverse engineering:
In
node_modules/brotli/build/encode.js, go to line 40 and search forfunction Cb. It should be the last one. It ends with the following part:return g|0. When I replaced this with a simple assignment & return, it stopped the error happening (e.g.:const abcd = g|0; return abcd).I just hopped on this problem so bear in mind the following:
encode.jsis platform dependent so this solution might be completely bad for you (I use debian linux with nodev10.16.0)