Read the statement by Michael Teeuw here.
Integrating an npm module that uses import
-
-
@sdetweil that’s not sufficient. There are two more modules imported by the picnic-api module. I could require them all in node_helper but that looks too of much a workaround for me. There should be another way.
-
@lavolp3 sometimes u get to do things that arent perfect. but get to move on.
-
- rename
node_helper.js
tonode_helper.mjs
worked in my test (did not do anything with the imported axios, but mm starts).
- rename
-
@karsten13 was node_helper loaded? i doubt it. its optional. so this doesnt help
-
@sdetweil no :crying_face:
may using esm library is one approach as described e.g. here https://blog.logrocket.com/how-to-use-ecmascript-modules-with-node-js/
-
@karsten13 in node… but we have a custom environment, that is not node pure…
-
i helped someone with a similar problem but the n module was wrutten in typescript and down compiled to js
-
@sdetweil @strawberry-3-141
I can’t get it working.
node 14.15 installed.When I
require
the “picnic-api” npm module the usual way I get the error message inside the "picnic-api module.import axios from "axios"; ^^^^^^ SyntaxError: Cannot use import statement outside a module
When I do the
import
like described in the readme the error originates in my node_helper.jsimport PicnicClient, { CountryCodes, ImageSizes, HttpMethods } from "picnic-api"; ^^^^^^ SyntaxError: Cannot use import statement outside a module
I’m lost. At least the environment of the picnic-api module should be a “pure node” environment, why does the
import
not work at least in that module?Changing the index.js inside picnic-api to an .mjs does not help.
Any more ideas?
-
@lavolp3 i do not know. i consider myself a node rookie, and a typescript noobie.
because i am away from my systems i am unable to try different solutions… at least a few more weeks
if u try w
node serverOnly
does it make a difference?
there the node engine is running the code, vs the engine thru electron…