Elm Native Module Not Found

Asked 3 months ago, Updated 3 months ago, 5 views

I wrapped the existing JS library in the native module to use it from the Elm app.However, I will moss with the last elm-make

# Command to test the single compilation.
# Actually, it is set up to compile with webpack and elm-webpack-loader.
$ elm-make app/frontend/elm/Mermaid.elm
I cannot find find module 'Native. Mermaid'.

Module 'Mermaid' is trying to import it.

Potential problems could be:
  * Misspelled the module name
  * Need to add a source directory or new dependency to elm-package.json

file placement:

$findapp/frontend/elm/-iname "Mermaid.*"

What's inside: Mermaid.elm

module Mermaid where
{-| ...

import Html exporting (Html)
import Native.Mermaid


What's inside: Native/Mermaid.js


// definition
  'use strict';

  if('values' in Elm.Native.Mermaid){
    return Elm.Native.Mermaid.values;


  return Elm.Native.Mermaid.values={

It's almost like a copy of the elm-markdown library, but how do I get through the compilation?


2022-09-30 12:07

1 Answers

Packages containing native modules must be clearly identified within elm-package.json.

"exposed-modules": [ ],
"dependencies": {

This is to ensure that packages containing JavaScript can be handled differently because the world of JavaScript is not subject to Elm's type checking and side effects are unlimited and dangerous.Packages containing native modules are also subject to review when uploading to the official package repository.

2022-09-30 12:07

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.