getting SyntaxError: Cannot use import statement outside a module while running in deployed java app
See original GitHub issueI need to run a simple node app from my Java project that expose one function.
I followed the logic on the documentation “Interact with Node.js” part and in local everything works, but when I try to do the same in the deployed java app I get SyntaxError: Cannot use import statement outside a module
when doing nodeRuntime.getExecutor(codeFile).executeVoid();
I already tried to put “type”: “module” in package.json or change the extension to .mjs without success.
this is the package.json:
{
"name": "banca_pdf",
"version": "1.0.0",
"description": "script to generate banca pdf",
"main": "pdf.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "pak1989",
"license": "ISC",
"dependencies": {
"pdfmake": "^0.2.4"
},
"devDependencies": {
"@types/pdfmake": "^0.1.21"
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
SyntaxError: Cannot use import statement outside a module
But that gets me another error: "Error: Plugin/Preset files are not allowed to export objects, only functions." Here are the dependencies I ...
Read more >Fix "cannot use import statement outside a module" in ...
This results in the error "Uncaught SyntaxError: cannot use import statement outside a module". If you've run into this error, it's possible ...
Read more >Cannot use import statement outside a module - YouTube
Are you using imports in a node.js application and running into the SyntaxError : Cannot use import statement outside a module error?
Read more >Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >How to fix 'Uncaught SyntaxError: Cannot use import ...
In this quick guide we'll look at how you can solve the very common error, “Uncaught SyntaxError: Cannot use import statement outside a ......
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
Nice work and thank you for sharing your solution with the community.
In the end I made it work with I think the option 1. I had to point to the library with his absolute path in the js file, went back and made the package.json look like this:
The way I call it in Java is the same as the express server example.
Thanks for the inputs!