1

I need to use some library to manage currencies (add, sum, floating point, etc.) in Adonis.js v4.

I found different libraries that should work (Diner.js, currency.js, money.js), but I am unable to use those libraries with Adonis.

For example with currency.js, I install it with npm

npm install --save currency.js

and then inside the controller I tried to use it with:

const currency = require('currency.js') //nada, but if I click on it it redirects me to the node modules folder
const currency = use('currency.js') //nada
const currency = require('currency.js/dist') //nada
const currency = require('currency.js/dist/currency.js') //nada

It always shows this error: Cannot find module 'currency.js' Require stack: - /srv/app/app/Controllers/Http/Common/AccountTransactionController.js - /srv/app/node_modules/require-stack/src/index.js - /srv/app/node_modules/require-stack/index.js - /srv/app/node_modules/@adonisjs/fold/src/Ioc/index.js - /srv/app/node_modules/@adonisjs/fold/index.js - /srv/app/server.js

I tried with the other two libraries and it's the same. Can you please help me import and use this/those library/libraries?

Agilulfo
  • 101
  • 3
  • 10
  • Did you try : https://github.com/scurker/currency.js/issues/88#issuecomment-362151839 @Agilulfo – crbast Dec 19 '20 at 19:08
  • Hi @crbast thank you for you help. Yes I did try that bt it doesn't work with Adonisjs 4 – Agilulfo Dec 21 '20 at 13:22
  • okay, can you share your `package.json`? thanks – crbast Dec 21 '20 at 17:13
  • You are right. It was my fault from the beginning. I'm using docker-compose as my development setup and even If I installed the library it wasn't saved inside the docker volume. Excuse me for wasting your time and thank you for helping me. Have a nice holiday! – Agilulfo Dec 22 '20 at 08:33
  • No problem, glad you found the solution. Have a nice holiday too :) – crbast Dec 22 '20 at 09:09

0 Answers0