• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Integrating an npm module that uses import

Scheduled Pinned Locked Moved Development
13 Posts 4 Posters 3.0k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Away
    sdetweil
    last edited by Feb 14, 2021, 12:30 AM

    i helped someone with a similar problem but the n module was wrutten in typescript and down compiled to js

    https://github.com/Mitica/public-holidays-js

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    L 1 Reply Last reply Feb 14, 2021, 7:47 PM Reply Quote 0
    • L Offline
      lavolp3 Module Developer @sdetweil
      last edited by Feb 14, 2021, 7:47 PM

      @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.js

              import 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?

      How to troubleshoot modules
      MMM-soccer v2, MMM-AVStock

      S 1 Reply Last reply Feb 14, 2021, 7:51 PM Reply Quote 0
      • S Away
        sdetweil @lavolp3
        last edited by sdetweil Feb 14, 2021, 7:54 PM Feb 14, 2021, 7:51 PM

        @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…

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • 1
        • 2
        • 2 / 2
        2 / 2
        • First post
          11/13
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy