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

    Newbee pb with "require" statement

    Help
    3
    6
    399
    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.
    • D
      dgrens last edited by

      Hi I’ve got a problem which must be linked to my newbee-ness in quasar/vue
      I’m starting from a basic project generated using the layout builder
      It works fine but if i start to do a require in the MainLayout.vue

      …
      </q-layout>
      </template>

      <script>

      	const whatever = require('mariadb');  // or in fact any other module from node_modules
      

      export default {
      data () {
      return {
      model: null,
      …

      then my page goes blank

      Can someone point me to what I’m doing wrong ?

      Thanks

      dobbel 1 Reply Last reply Reply Quote 0
      • beatscribe
        beatscribe last edited by

        Can you open the developer tools in your browser, is there anything in the Console tab? Might help to see your package.json too.

        D 1 Reply Last reply Reply Quote 0
        • dobbel
          dobbel @dgrens last edited by

          @dgrens said in Newbee pb with "require" statement:

          require

          use import instead:

          import { somePart } 'of/a/package';
          
          
          D 1 Reply Last reply Reply Quote 0
          • D
            dgrens @beatscribe last edited by

            @beatscribe the console tab is “mute” :

            DONE Compiled successfully in 308ms 5:29:34 PM

            N App dir… /home/denis/apptest
            App URL… http://localhost:8080
            Dev mode… spa
            Pkg quasar… v1.15.2
            Pkg @quasar/app… v2.1.14
            Transpiled JS… yes (Babel)

            and I haven’t changed anything in package.json:

            “productName”: “Quasar App”,
            “author”: “XXXXXXXX”,
            “private”: true,
            “scripts”: {
            “lint”: “eslint --ext .js,.vue ./”,
            “test”: “echo “No test specified” && exit 0”
            },
            “dependencies”: {
            “@quasar/extras”: “^1.0.0”,
            “axios”: “^0.21.1”,
            “core-js”: “^3.6.5”,
            "mariadb": “^2.5.3”,
            “quasar”: “^1.0.0”
            },
            “devDependencies”: {
            “@quasar/app”: “^2.0.0”,
            “babel-eslint”: “^10.0.1”,
            “eslint”: “^6.8.0”,
            “eslint-config-prettier”: “^6.9.0”,
            “eslint-loader”: “^3.0.3”,
            “eslint-plugin-vue”: “^6.1.2”
            },
            “browserslist”: [
            “last 10 Chrome versions”,
            “last 10 Firefox versions”,
            “last 4 Edge versions”,
            “last 7 Safari versions”,
            “last 8 Android versions”,
            “last 8 ChromeAndroid versions”,
            “last 8 FirefoxAndroid versions”,
            “last 10 iOS versions”,
            “last 5 Opera versions”
            ],
            “engines”: {
            “node”: “>= 10.18.1”,
            “npm”: “>= 6.13.4”,
            “yarn”: “>= 1.21.1”
            }
            }

            1 Reply Last reply Reply Quote 0
            • D
              dgrens @dobbel last edited by

              @dobbel

              It improves a bit for example

              import {cookie} from ‘cookie’;

              is ok (I see the quasar skeleton app in my browser)

              but if i try with mariadb (which is THE module i want to use

              import {mariadb} from ‘mariadb’;

              the page is empty

              dobbel 1 Reply Last reply Reply Quote 0
              • dobbel
                dobbel @dgrens last edited by dobbel

                @dgrens

                import {mariadb} from ‘mariadb’;

                Eum you will never be able to use mariadb directly inside Quasar. Quasar is front end only. MariaDB is for nodejs backend/server applications.

                You need a NodeJs backend like express to access the database(mariadb).

                For example:
                Quasar <=> Express <=> Mariadb

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