Getting started with Nuxt 3
See original GitHub issueHi there! I’m having a bit of trouble getting this to work in a brand new Nuxt 3 (RC) application. I’ve follow the examples and read the issues but I still can’t get it to work. My project has only one component called drawflow.vue
:
<script lang="ts" setup>
import { render } from "vue";
import Drawflow from "drawflow";
import styleDrawflow from "drawflow/dist/drawflow.min.css";
const editor = ref<Drawflow | Object>({});
const Vue = { version: 3, h, render };
const internalInstance = getCurrentInstance();
internalInstance.appContext.app._context.config.globalProperties.$df = editor;
onMounted(() => {
var id = document.getElementById("drawflow");
editor.value = new Drawflow(
id,
Vue,
internalInstance.appContext.app._context
);
(editor.value as Drawflow).start();
});
</script>
<template>
<div id="drawflow"></div>
</template>
that is being used in the app.vue
file in the source directory of the project:
<template>
<Drawflow />
</template>
<script setup lang="ts"></script>
Also, this is my nuxt.config.ts
file:
import { defineNuxtConfig } from "nuxt";
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
build: {
transpile: ["drawflow"],
}
});
and my package.json
:
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"@types/drawflow": "^0.0.4",
"nuxt": "3.0.0-rc.6"
},
"dependencies": {
"drawflow": "^0.0.59"
}
}
The thing is, when I run the local server, this error pops up:
[nuxt] [request error] Cannot set properties of undefined (setting 'Drawflow')
at ./.nuxt/dist/server/server.mjs:3410:192
at $id_fwiUH6v28r (./.nuxt/dist/server/server.mjs:3410:197)
at __instantiateModule__ (./.nuxt/dist/server/server.mjs:3547:9)
at __ssrLoadModule__ (./.nuxt/dist/server/server.mjs:3485:25)
at ssrImport (./.nuxt/dist/server/server.mjs:3510:13)
at $id_BMrEYGZ7G0 (./.nuxt/dist/server/server.mjs:3360:37)
at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:3547:3)
I’ve been stuck on this for a while, and would REALLY appreciate any help! Thank you!
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Installation · Get Started with Nuxt
Get started with Nuxt quickly with our online starters or start locally with your terminal. Play Online. You can start playing with Nuxt...
Read more >Installation - Nuxt
Another way to get started with Nuxt is to use CodeSandbox which is a great way for quickly playing around with Nuxt and/or...
Read more >Nuxt 3 first steps. - ITNEXT
Nuxt 3 first steps. · Installation · Vite · ESLint and Prettier · Pages and Layouts · Autoimports · Page Meta · Page...
Read more >Getting Started with Nuxt js as a Beginner - Vue School Blog
To start a new Nuxt project run npx nuxi init [project-name] in your terminal. Open your new project in your favorite code editor...
Read more >Getting started with Nuxt 3 - Section.io
Nuxt 3 is a Hybrid Vue Framework that allows us to use Vue.js and, most importantly, Vue.js 3 to build server-side rendered applications....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just did a test with nuxt 3.
app.vue
components/drawflow.vue
And component node 1: components/node1.vue
Preview:
In nuxt config I have not had to transpile. Default file.
Installed nuxt with:
The transpilation is surely only for nuxt2 i believe in the first versions.
I added the stylo in the same component. I didn’t have to add it in the config. But it is equally correct.