Newbee pb with "require" statement
-
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
-
Can you open the developer tools in your browser, is there anything in the Console tab? Might help to see your package.json too.
-
@dgrens said in Newbee pb with "require" statement:
require
use import instead:
import { somePart } 'of/a/package';
-
@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”
}
} -
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
-
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