i am learning how to build a js module and upload to npm and install back into nuxt and try to use the function inside. trying to understand the proccess to build a module. but i keep getting error, i try to simple the module much as possible can anyone tell me what i miss out ?
module – dayuntilxmas
github enter link description here
dayuntilxmas
- README.md
- index.js
- package.json
index.js
export function greetPerson(name) {
return `Hello ${name}`;
}
nuxt/pages/index.vue
<template>
<div>
<h1>this is plugins test framework</h1>
</div>
</template>
<script>
import {
greetPerson
} from 'dayuntilxmas'
export default {
data() {
const greet = greetPerson()
return {
greet
}
},
mounted() {
console.log(this.greet('jade'))
}
}
</script>
so what do i missout ? i see some said need to include a html file inside module, but isit needed for some reason ?
the error it return was “Unexpected token ‘export'”