No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Dependency was not found using a npm package

    Help
    4
    9
    4556
    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.
    • T
      twin322 last edited by twin322

      I wanted to use the npm nomnoml package in Quasar and got an error during build.

      This dependency was not found: fs in ./node_modules/nomnoml/dist/nomnoml.js
      To install it, you can run: npm install --save fs 
      

      my script part of the page looks like this:

      <script>
      var nomnoml = require('nomnoml');
      var src = '[<start>st]->[<state>plunder]'
      export default {
        mounted(){
          console.log(nomnoml.renderSvg(src)); 
        }
      }
      </script>
      

      Did i miss something? I’ve read that is has to do something with webpack and that i have to add something like…
      node: {
      fs: ‘empty’
      }

      I hope you can help

      1 Reply Last reply Reply Quote 0
      • benoitranque
        benoitranque last edited by

        you should be using ES6 import instead of require

        1 Reply Last reply Reply Quote 0
        • T
          twin322 last edited by

          ok thanks. i’ve changed to import * as nomnoml from ‘nomnoml’;
          Now i got an WEBPACK_IMPORTED_MODULE_0_nomnoml__.color255 is not a function :). I should say that i’ve also got this error by using require()

          It could be that I’m just to stupid to use this library 😃

          btw. the fs error i solved with
          extendWebpack (cfg) {
          cfg.node = {
          fs: ‘empty’
          }
          }

          1 Reply Last reply Reply Quote 0
          • a47ae
            a47ae last edited by a47ae

            Hey, from looking at the package source (I assume it is this one https://github.com/skanaar/nomnoml) my guess is that for waht ever reason webpack loads the cli version.
            There are two releases, one for the web and one for nedjs and the cli: https://github.com/skanaar/nomnoml/tree/master/dist

            In your error it says This dependency was not found: fs in ./node_modules/nomnoml/dist/nomnoml.js
            This means that webpack tries to resolve the fs package, which is a default package for nodejs to access the filesystem and which is not usable in the browser, only in nodjs apps.

            The strange thing is that the path in the error points to the non cli version.

            Also your use of import is wrong. import * as ...is used when multiple exports are defined on the package. In this case you should use import nomnoml from 'nomnoml' .
            Please try and report if this fixes the error.

            P.S.: This forum supports markdown. If you want to post code blocks, please escape them with thre backticks (```) at the beginning and at the end of the code block

            1 Reply Last reply Reply Quote 1
            • T
              twin322 last edited by twin322

              Hi,

              thanks for your help I changed my code and think that it’s nearly correct.

              import nomnom from 'nomnoml'
              
              export default {
                name:"App",
                methods:{
                  click(){
                    var canvas = document.getElementById('target');
                    var src = '[nomnoml] is -> [awesome]';      
                    nomnom.draw(canvas,src)
                  }
                }
              }
              

              There is just one error left
              Error in event handler for "click": "TypeError: _.object is not a function"

              I’ve tried the same code in a simple vue template from this git account
              https://github.com/vuejs-templates/webpack and it works, but in quasar I encounter the error.

              1 Reply Last reply Reply Quote 0
              • a47ae
                a47ae last edited by

                _.object is not a function looks like it is referring to underscore.js which is a dependency of nomnoml.
                Do you happen to include underscore.js as dependency on your project? Maybe it is a version mismatch

                1 Reply Last reply Reply Quote 0
                • T
                  twin322 last edited by twin322

                  Due to this problem I just created a new quasar project for testing, which has no underscore.js as a module dependency. I will take a closer look into the dependencies of the template from the repo and the .quasar deps. Maybe I’ll find some difference.
                  I’ve just noticed the lodash dependency… I will look into that

                  1 Reply Last reply Reply Quote 0
                  • T
                    twin322 last edited by

                    Ok i solved the problem by downgrading the lodash package using
                    npm install lodash@3.7.0
                    I hope this will not interfere with some other quasar functionalities 😃
                    Now it’s working fine and i can use the package.

                    thanks for your help 🙂

                    1 Reply Last reply Reply Quote 1
                    • rstoenescu
                      rstoenescu Admin last edited by

                      Quasar doesn’t uses lodash, so you’re safe with whatever version that you need.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post