• 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.

How do I install dependencies using npm when MagicMirror is in a Docker?

Scheduled Pinned Locked Moved Troubleshooting
18 Posts 3 Posters 19.1k 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 Offline
    smithbill17
    last edited by Jan 18, 2021, 4:34 PM

    Well the Snille/MMM-homeassistant-sensors module just says:

    Installation
    In your terminal, go to your MagicMirror's Module folder:
    
    cd ~/MagicMirror/modules
    Clone this repository:
    
    git clone https://github.com/Snille/MMM-homeassistant-sensors
    Enter the folder:
    
    cd MMM-homeassistant-sensors
    Install Node-Modules (The MaterialDesignIcons webfont icon names can be used.).
    
    npm install
    

    and the leinich/MMM-homeassistant-sensors module just says:

    Navigate into your MagicMirror's modules folder and clone this repository: cd ~/MagicMirror/modules && git clone https://github.com/leinich/MMM-homeassistant-sensors.git
    
    If you want to use icons for the sensors download the MaterialDesignIcons webfont from https://github.com/Templarian/MaterialDesign-Webfont/archive/master.zip and unzip the folder: cd ~/MagicMirror/modules/MMM-homeassistant-sensors && wget https://github.com/Templarian/MaterialDesign-Webfont/archive/master.zip && unzip master.zip
    

    I tried downloading and unzipping the master.zip file and running the npm install command in the directory (in the docker container) as you suggested. After restarting my MagicMirror2 container, nothing was any different.

    Clearly there is some ‘piece of the jigsaw’ that i’m missing.

    1 Reply Last reply Reply Quote 1
    • K Offline
      karsten13
      last edited by Jan 18, 2021, 7:55 PM

      you’re probably all too young to even know what those were

      unfortunately not …

      After restarting my MagicMirror2 container, nothing was any different.

      I think there is nothing different before you change the icons in your config.

      The module from Snille already includes the https://materialdesignicons.com/ (no extra installation needed except npm install). But did you use an icon name in your config as described in the readme?

      			{
      				sensor: "binary_sensor.washing_machine",
      				name: "Washing Machine",
      				icons: [{
      						"off": "washing-machine-off",
      						"on": "washing-machine"
      					}
      				],
      				replace: [{
      						"on": "Working",
      						"off": "Idle"
      					}
      				]
      			},
      
      

      Every icon name from https://materialdesignicons.com/ should work in “on”/“off”.

      1 Reply Last reply Reply Quote 0
      • S Offline
        smithbill17
        last edited by Jan 19, 2021, 7:14 AM

        Hi, thanks again for assisting.

        Yes, I updated my config.js with some sensor entries using some of the icons as listed in the leinich module example. So my config.js module looks like this:

        module: 'MMM-homeassistant-sensors',
            position: 'top_right',
            config: {
              host: "MY IP",
              port: "MY PORT",
              https: false,
              token: "MY TOKEN",
              values: [
              {
                sensor: "sensor.load_1m",
              },
              {
                sensor: "sensor.load_5m",
              },
              {
                sensor: "sensor.wifi_level",
              },
              {
                sensor: "sensor.kittytemp_temp",
              },
              {
                sensor: "switch.diningroom_lamp",
        	icons: [{
        	  "state_off": "lightbulb-outline",
        	  "state_on": "lightbulb-on-outline"
        	}]
              },
              {
                sensor: "switch.heat_mats",
        	icons: [{
        	  "state_off": "lightbulb-outline",
        	  "state_on": "lightbulb-on-outline"
        	}]
              },
              {
                sensor: "switch.kitty_mat",
        	icons: [{
        	  "state_off": "lightbulb-outline",
        	  "state_on": "lightbulb-on-outline"
        	}]
              },
              {
                sensor: "switch.satellite",
        	icons: [{
        	  "state_off": "lightbulb-outline",
        	  "state_on": "lightbulb-on-outline"
        	}]
              }
              ]
            }
          },
        

        So, as best I could tell, “lightbulb-outline” and “lightbulb-on-outline” are included in the Material Design Icons.

        Obviously I’m being a bit dumb somehow, but I’m not currently seeing where.

        1 Reply Last reply Reply Quote 0
        • S Offline
          smithbill17
          last edited by Jan 19, 2021, 7:25 AM

          Incidentally, your post said that the module from Snille “included” the Material Design Icons - where? Does the npm install command somehow download them?

          Snille’s instructions say: “Install Node-Modules (The MaterialDesignIcons webfont icon names can be used.).”

          What exactly does “Install Node-Modules” mean?? I haven’t done anything more than git clone his module, then ran npm install inside the docker container as you explained.

          1 Reply Last reply Reply Quote 0
          • S Offline
            smithbill17
            last edited by Jan 19, 2021, 9:30 AM

            Hoorah! I got it working - thanks to your help :)

            As you had said “The module from Snille already includes the https://materialdesignicons.com/” i decided to remove the leinich version of the module and instead installed the Snille version.

            And now that I know how to run ‘npm install’ INSIDE the docker container, i did that and noticed that a directory called “node_modules” was created inside the MMM-homeassistant-sensors directory. I also noticed a “node_modules” directory inside the docker container at the ‘/opt/magic_mirror/’ level - i’ve no idea if thats meant to be there or its the result of me running ‘npm install’ whilst in the wrong directory - either way, it doesn’t seem to affect anything, so I stayed well clear of it.

            After installing the Snille module and running ‘npm install’ INSIDE the docker container, i still couldn’t get my icons appearing, until i realised that the config.js for leinich’s version is subtly different to Snilles:

            leinch’s says:

            icons: [{
              "state_off": "lightbulb-outline",
              "state_on": "lightbulb-on-outline"
            }]
            

            whereas Snille’s says:

            icons: [{
              "off": "lightbulb-outline",
              "on": "lightbulb-on-outline"
            }]
            

            so the difference being “state_off” and just “off”.

            Anyway, i now have it working - so a big thank you for your help!

            Hopefully my struggles will help anyone else reading this thread (in particular the bit on how to run ‘npm install’ INSIDE the docker container). Thank you.

            1 Reply Last reply Reply Quote 0
            • S Offline
              smithbill17
              last edited by Jan 19, 2021, 10:47 AM

              Sorry - one more question:

              If there is a MagicMirror2 update, and I remove my MagicMirror docker container and re-add it in order to get the latest version of MagicMirror2, do I then have to repeat the ‘npm install’ command inside the new docker container to get dependencies and MaterialDesignIcons installed? Or are the existing files & directories kept on the host OS and the MagicMirror2 container simply has links to the already existing directories on the host and so everything should just work?

              1 Reply Last reply Reply Quote 0
              • K Offline
                karsten13
                last edited by Jan 19, 2021, 6:08 PM

                I don’t know your docker setup but some folders (config, modules, css) should be mounted from the host. So your module data is on the host, not in the container and there is no need to run npm install in your module folder after updating the docker image (mm version).

                You have to do this if the module is updated (and uses new/updated dependencies).

                S 1 Reply Last reply Jan 19, 2021, 7:30 PM Reply Quote 0
                • S Offline
                  smithbill17 @karsten13
                  last edited by Jan 19, 2021, 7:30 PM

                  @karsten13 Excellent - I think that’s what I was expecting to happen. Thank you so much for all your help & advice.

                  I hope this thread proves useful to other MagicMirror ‘newbies’ like me.

                  1 Reply Last reply Reply Quote 0
                  • 1
                  • 2
                  • 2 / 2
                  2 / 2
                  • First post
                    14/18
                    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