Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Unexpected token 'export' - lodash-es (Failed to make bytecode) #976

Closed
lbertoncello opened this issue Sep 14, 2020 · 5 comments
Closed

Comments

@lbertoncello
Copy link

After running the following command using pkg 4.4.9

pkg -t node12-win .\src\app.js --debug

I've got the following error:

E:\snapshot\upbotswa\node_modules\typescript-parser\node_modules\lodash-es\lodash.js:10
export { default as add } from './add.js';
^^^^^^

SyntaxError: Unexpected token 'export'
at new Script (vm.js:89:7)
at Socket. ([eval]:18:19)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
E:\snapshot\upbotswa\node_modules\typescript-parser\node_modules\lodash-es\lodash.js:10
export { default as add } from './add.js';
^^^^^^

SyntaxError: Unexpected token 'export'
at new Script (vm.js:89:7)
at Socket. ([eval]:18:19)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
Warning Failed to make bytecode node12-x64 for file E:\snapshot\upbotswa\node_modules\typescript-parser\node_modules\lodash-es\lodash.js

I'm using Node 12.18.3 on Windows. I think it's an issue related to es6 modules. I've tried many solutions and workarounds that I read on old Issues (without solution), but none of them has worked. Someone have a workaround to help me?

@matheusm821
Copy link

same error here

@bo-516
Copy link

bo-516 commented Mar 4, 2021

same error...

@hipstersmoothie
Copy link
Contributor

hipstersmoothie commented Mar 4, 2021

Pkg currently doesn't support import/export via native node js modules. There's a few things that need to happen to make it possible:

  1. Update pkg-fetch with newer node releases that include the inflated support
  2. Changes to pkg to detect "type: module" and bundle the code using modules instead of requires

In the meantime you might be able to first compile your code with something like Babel to compile down to requires and the package that.

@hipstersmoothie
Copy link
Contributor

Closing because this is a dupe of #782

@pxim
Copy link

pxim commented Aug 13, 2021

same error here

I write it this way, the Update pkg-fetch with newer node releases that include the inflated support
files?.length <= 0

Removed ?, it's ok !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants