Pkg: Failed to make bytecode node8-x64 for file

Created on 9 Mar 2018  路  13Comments  路  Source: vercel/pkg

on win , I install pkg and run :
D:\wordspace\xephangtudong>pkg .\src\server\index.js

[email protected]
Targets not specified. Assuming:
node8-linux-x64, node8-macos-x64, node8-win-x64
Warning Failed to make bytecode node8-x64 for file /snapshot/xephangtudong/src/server/index.js
Warning Failed to make bytecode node8-x64 for file /snapshot/xephangtudong/src/server/api/apiGetIndexNum.js
Warning Failed to make bytecode node8-x64 for file /snapshot/xephangtudong/src/server/io/io-service.js
Warning Failed to make bytecode node8-x64 for file /snapshot/xephangtudong/src/server/api/apiUser.js
Warning Failed to make bytecode node8-x64 for file /snapshot/xephangtudong/src/server/api/apiPrinter.js

how to fix it! tks all!!

Most helpful comment

This is mine:

SyntaxError: Unexpected token export
/snapshot/proj1/node_modules/safefs/es6/lib/safefs.js:178
export default safefs
^^^^^^

All 13 comments

Rerun with the --debug flag and update this issue with the errors you see.
pkg --debug .\src\server\index.js

Same issue here :

/snapshot/Kupiki-Hotspot-Admin-Backend/src/api/hotspot.js:1
(function (exports, require, module, __filename, __dirname) { import resource from 'resource-router-middleware';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at Socket.<anonymous> ([eval]:18:19)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)
> Warning Failed to make bytecode node8-x64 for file /snapshot/Kupiki-Hotspot-Admin-Backend/src/api/hotspot.js

Same error multiple times on different files. I guess that the source syntax is incorrect somewhere

This is mine:

SyntaxError: Unexpected token export
/snapshot/proj1/node_modules/safefs/es6/lib/safefs.js:178
export default safefs
^^^^^^

Im having this error as well on Ubuntu, node version 8

FWIW - I encountered this same error.

Through trial and error, I figured out that I had a module that was 'required' TWICE.

After I removed the redundant require(), pkg 'compiled' successfully.

I'm encountering this issue with safefs as well

SyntaxError: Unexpected token export
    at Socket.<anonymous> ([eval]:18:19)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:597:20)
C:\snapshot\wos-worker\node_modules\safefs\es6\lib\safefs.js:178
export default safefs
^^^^^^

No solution...?

npm install [email protected] -g
Will use node v8.0.0 . This solved my issue

I was with the same problem, I managed to solve by transpiling the code with babel before running the pkg.

node v8.11.1
pkg 4.3.7

pkg conf and scripts in package.json

"bin": "build/index.js",
"pkg": {
  "assets": [
    ".env"
  ],
  "scripts": [
    "build/**/*.js"
  ]
},
"scripts": {
  "build": "babel src -d ./build",
  "clean": "rm -rf build dist && mkdir build dist",
  "pack": "npm run clean && npm run build && pkg . --out-path ./dist -t node8-win-x64"
}

I was with the same problem, I managed to solve by transpiling the code with babel before running the pkg.

node v8.11.1
pkg 4.3.7

pkg conf and scripts in package.json

"bin": "build/index.js",
"pkg": {
  "assets": [
    ".env"
  ],
  "scripts": [
    "build/**/*.js"
  ]
},
"scripts": {
  "build": "babel src -d ./build",
  "clean": "rm -rf build dist && mkdir build dist",
  "pack": "npm run clean && npm run build && pkg . --out-path ./dist -t node8-win-x64"
}
  "scripts": {
    "build": "babel src -d ./build",
    "clean": "rm -rf build dist && mkdir build dist",
    "pkg-win": "yarn clean && yarn build && pkg . --out-path ./dist -t node8-win-x64",
    "pag-mac": "yarn clean && yarn build && pkg . --out-path ./dist -t node8-macos-x64",
    "pkg-linux": "yarn clean && yarn build && pkg . --out-path ./dist -t node8-linux-x64"
  }

Same issue here except with vue-loader.

\node_modules\vue-loader\lib\runtime\componentNormalizer.js:7
export default function normalizeComponent (
^^^^^^

SyntaxError: Unexpected token export
    at Socket.<anonymous> ([eval]:18:19)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:601:20)

Will try running everything through babel which seems to have worked for some.

EDIT:
Looks like running everything through babel didn't fix the issue in my case.

Same issue here except with vue-loader.

\node_modules\vue-loader\lib\runtime\componentNormalizer.js:7
export default function normalizeComponent (
^^^^^^

SyntaxError: Unexpected token export
    at Socket.<anonymous> ([eval]:18:19)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:601:20)

Will try running everything through babel which seems to have worked for some.

EDIT:
Looks like running everything through babel didn't fix the issue in my case.

Are you trying to pack an UI with pkg? i think that pkg isn't suitable for that, maybe you should use other package like electron.

I'm trying to package a nuxt application, specifically the server.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gillez picture gillez  路  4Comments

Ks89 picture Ks89  路  4Comments

Nilesh0101 picture Nilesh0101  路  4Comments

j-brown picture j-brown  路  4Comments

Admiral-Enigma picture Admiral-Enigma  路  3Comments