I've encountered an issue while trying to use formulja.js in a Vue project. When I import it and attempt to utilize the PPMT function, an error occurs. Unfortunately, I'm unable to identify the exact nature of the error or how to resolve it. If anyone could provide assistance, I would greatly appreciate it.
ERROR Failed to compile with 1 error 5:23:41 PM
error in ./node_modules/@formulajs/formulajs/lib/esm/index.mjs
Module parse failed: Unexpected token (1453:25)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
|
> delimiter = delimiter ?? '';
|
| let flatArgs = flatten(args);
@ ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Table.vue?vue&type=script&lang=js& 59:0-45 74:24-33
@ ./src/components/Table.vue?vue&type=script&lang=js&
@ ./src/components/Table.vue
@ ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Home.vue?vue&type=script&lang=js&
@ ./src/components/Home.vue?vue&type=script&lang=js&
@ ./src/components/Home.vue
@ ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
@ ./src/App.vue?vue&type=script&lang=js&
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.178.69:8081&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
This is how I am attempting to use it:
<script>
import formulajs from "@formulajs/formulajs"
export default {
data() {
return {
rate: 0,
pv: 0,
nper: 0,
};
},
computed:{
totalPPMT() {
let per = 1;
let ppmt = 0
while(this.nper >= 0){
let calc_ppmt = formulajs.PPMT(this.rate,per,this.nper,this.pv,0,0)
per++
ppmt += calc_ppmt
}
return ppmt;
},
},
<script/>