node-fetch/fetch-blob

node failing due to unexpected character '#'

pkieltyka opened this issue · 8 comments

Module parse failed: Unexpected character '#' (45:2)
|  */
| class BlobDataItem {
>   #path
|   #start

seems to be a new JS language feature I've never seen either, and my js compiler is having a challenge as well: https://github.com/node-fetch/fetch-blob/blob/main/from.js#L60-L61

@pkieltyka which version of Node are you running? You need at least 12.20 or 14.13, as indicated here:

"node": "^12.20 || >= 14.13"

Have the same problem with node 16.15.0 in a nuxt project. I suspect Webpack when importing from thenode_modules, seems to be missing Babel for the transpile.

I use the "Private Class Fields" in my project, so Babel Configuration works.

When I do the transpile via nuxt I still get these warnings:

image

@ThornWalli are you packaging for the browser? The browser already has it's own Blob and File, this is for the Node.js runtime...

I use the package ‘cross-blob‘.
https://www.npmjs.com/package/cross-blob

The background here is the client and server build.

Do you actually get any errors, or are you just getting warnings about node:* imports? This issue is specifically about the Module parse failed: Unexpected character '#' error...

Think you should rather do some code splitting, do some conditional loading to load fetch-blob only when needed.

Got no more response...
just update your dependencies, all evergreen browser and backends all do support private class field right now...