Unexpected Token
See original GitHub issue/node_modules/upscaler/dist/browser/esm/index.js:1
export { default, } from './upscaler';
^^^^^^
SyntaxError: Unexpected token 'export'
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >Have a JavaScript Unexpected Token Error? Check Your Syntax
The JavaScript's parser expects tokens and symbols in a particular order, with relevant values or variables in between. Often, an Unexpected ...
Read more >syntax error: unexpected token - javascript - Stack Overflow
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >JavaScript Error Handling: Unexpected Token - GeeksforGeeks
Not follow them throws an error.An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + –...
Read more >How to fix JavaScript unexpected token error
As you write your JavaScript application, the unexpected token error always occurs because JavaScript expected a specific syntax that's not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I opened https://github.com/hollowshiroyuki/Timi_OCR_Proto/pull/1/files which should resolve the issues you’re seeing (I’m not familiar with TesseractJS, but the script completes without errors).
Some things:
@tensorflow/tfjs-node
as an explicit dependency alongside UpscalerJSrequire
to load Upscaler in a Node environment - more on this below<img />
tag.model.json
file (alternatively you can import a specific model with something like this).On the subject of needing to load the Node version with
require
: we bundle the library in a few flavors:Which has been roughly sufficient, as most Node projects can consume CJS (either because they’re written in CJS themselves, or can use a transpiler) and most browser-based projects can consume either ESM (via a transpiler) or load the UMD script tag.
It gets a bit trickier with the use of a tool like
ts-node
, which, as far as I understand, is transpiling your ESM Node source code on the fly withtsc
into CommonJS, but which is expecting imported libraries to also be ESM.The reason I haven’t provided an ESM-compatible Node version of the library so far is that Node also supports native ESM, but via the use of
.mjs
extensions, which (in the limited investigation I did) wrecked havoc with the existing build process.That said, this is good motivation to pick that investigation back up, as you probably are not the only one who will run into that issue (and it’s weird to need a single
require()
tag amongst the otherimport
tags).Awesome, great to hear!
One other thing I should have mentioned, because you’re in Node, you should experiment with providing an explicit model. I’d recommend either the 4x or 8x models from
esrgan-thick
(the 8x image is not shown, which is a bug in the documentation, but you should be able to import it). You can also explicitly specify the model you’re using now,GANS
fromesrgan-legacy
.The reason I recommend this is because UpscalerJS is using the
default-model
by default, which currently is the GANS model (slow and more precise) but which will be switching to the 2xesrgan-slim
model (fast, less precise). For your use case, I think you probably want the most precise model.