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

    Migrating Nuxt project to Quasar - Absolute path

    Help
    1
    2
    303
    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.
    • M
      Manieck last edited by

      Hi,

      I just started to migrate project from Nuxt to Quasar. I have a problem with importing modules.
      I would like to import using absolute path like Nuxt:

      import { objectActions } from '~/util/defs';
      

      but it is not working

      This dependency was not found:
      
      * ~/util/defs in ./node_modules/babel-loader/lib??ref--1-0!./node_modules/@quasar/app/lib/webpack/loader.auto-import.js?kebab!./node_modules/vue-loader/lib??vue-loader-options!./src/pages/Index.vue?vue&type=script&lang=js&
      
      To install it, you can run: npm install --save ~/util/defs
      

      It doesn’t work either

      import { objectActions } from '@util/defs';
      

      After change to relative path is OK.

      import { objectActions } from '../util/defs';
      

      I tried to move my module to folder components, pages and it’s work!

      import { objectActions } from 'components/defs';
      

      I guess it’s a Webpack problem but I don’t know much about it yet.

      How to get to the root of the project in Quasar?
      How can I define an additional folder so that I can reference it like ‘components/…’, ‘pages/…’, etc.?

      Regards

      M 1 Reply Last reply Reply Quote 0
      • M
        Manieck @Manieck last edited by Manieck

        I think I found a solution. I don’t know if it’s the correct, but it works.
        In the quasar.conf.js file I added:

        // Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build
            build: {
              ...
              extendWebpack (cfg) {
                cfg.resolve.alias = {
                  ...cfg.resolve.alias,
                  '~/util': path.resolve(__dirname, './src/util')
                }
                ...
              }
              ...
            },
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post