Overview In main.js, add
import Three from 'three'
Vue.use(Three)
Start dev server with npm run dev. Expected behavior The Vue project should load without errors. Actual behavior The dev server gives this warning:
warning in ./src/main.js
7:8-14 "export 'default' (imported as 'Three') was not found in 'three'
And the browser's js console displays the error:
Uncaught TypeError: Cannot read property 'installed' of undefined
at Function.Vue.use (eval at <anonymous> (app.js:723), <anonymous>:3443:15)
at eval (eval at <anonymous> (app.js:778), <anonymous>:14:45)
at Object.<anonymous> (app.js:778)
at __webpack_require__ (app.js:660)
at fn (app.js:84)
at Object.<anonymous> (app.js:964)
at __webpack_require__ (app.js:660)
at app.js:709
at app.js:712
The "export default was not found" error occurs when we try to import as default from a module that doesn't have a default export. To solve the error, make sure the module has a named export and wrap the import in curly braces, e.g. import {myFunction} from './myModule' .
Every module can have two different types of export, named export and default export. You can have multiple named exports per module but only one default export.
Solution: You Just need to Downgrade the Framer motion version to “4.1. 17” in your package. json file and then run npm install Now, Your error must be solved.
The export statement is used when creating JavaScript modules to export objects, functions, variables from the module so they can be used by other programs with the help of the import statements.
It's happening because there are no default export made in the ThreeJS library, so you can import everything like this:
import * as Three from 'three';
Also you don't need the Vue.use
since this is not VueJS Plugin.
Since there are no default export, you are able to import specific part from ThreeJS, like this:
import { Scene } from 'three';
You can't use Three.js directly, you need a Vue wrapper around it, you can find one here
If you do want to use it directly, you have several options:
Import it in every file and use it:
import Three from 'three'
Three.doSomething
Import it in the main file and put it on the window object:
window.Three = require('Three');
Add it to the Vue instance (preferred way):
import Three from 'three';
Object.definePrototype(Vue.prototype, '$three', { value: Three});
and then you can refer to it like this: this.$three
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With