docx: Module parse failed: Unexpected token (11509:70)

I have an issue. When I import a library and use any component I get an error. How can I fix that? I have no clues or guesses,

Module parse failed: Unexpected token (11509:70)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
(Source code omitted for this binary file)```

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29 (8 by maintainers)

Most upvoted comments

@momoca Worked around this error by downgrading to 8.0.4

re-opened the issue. I will have another shot at it later

Edit, made a PR here: https://github.com/dolanmiu/docx/pull/2492

 ERROR  Failed to compile with 1 errors                                                                         21:04:07

 error  in ./node_modules/docx/build/index.js

Module parse failed: Unexpected token (9836:70)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

 @ ./src/ipcMain.js 3:13-28
 @ ./src/background.ts
 @ multi ./src/background.ts

I believe I too am running into this issue of not being able to import and use components from the library. I have a small and simple JavaScript React app (also created with create-react-app).

Any import statements are giving me errors at the moment; even when I try to just run the simple ‘Basic Usage’ example from the top of the docx.js.org page I get the error ‘Can’t import the named export ‘Document’ (imported as ‘Document’) from default-exporting module (only default export is available)’ for each component (Document, Packer, Paragraph, etc).

Some dependencies I am currently using are “react”: “^18.2.0”, “react-scripts”: “5.0.1”, “docx”: “^8.2.0”, among others.

I’m having the same issues in my angular app: “Error: export ‘Document’ (imported as ‘Document’) was not found in ‘docx’ (module has no exports)” …and the same for all other imports. Nevermind. I was using 8.2.1. 8.2.2 fixed it.

I believe I too am running into this issue of not being able to import and use components from the library. I have a small and simple JavaScript React app (also created with create-react-app).

Any import statements are giving me errors at the moment; even when I try to just run the simple ‘Basic Usage’ example from the top of the docx.js.org page I get the error ‘Can’t import the named export ‘Document’ (imported as ‘Document’) from default-exporting module (only default export is available)’ for each component (Document, Packer, Paragraph, etc).

Some dependencies I am currently using are “react”: “^18.2.0”, “react-scripts”: “5.0.1”, “docx”: “^8.2.0”, among others.