Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Node Modules from Referencing Global Location

Once after pulling the latest update from Git, I faced an issue using ngx-material-timepicker along with the luxon library.

(Please note, ngx-material-timepicker is not a new introduction to the project, it has been used for some time)

However, I'm encountering a module resolution error related to luxon when building the project.

enter image description here

When I checked the errors in each .ts file, I noticed that Luxon is referenced from the global TypeScript types directory. (AppData\Local\Microsoft\TypeScript\5.2\node_modules\@types) and not from (node_modules\@types) within my project. This discrepancy is causing a module resolution error when building the project.

enter image description here

I copied luxon module from a global location and pasted it into my project's local node_modules\@types directory. issues are fixed up to a certain level and only this issue is occurring now.

./node_modules/ngx-material-timepicker/fesm2015/ngx-material-timepicker.js:8:0-39 - Error: Module not found: Error: Can't resolve 'luxon' in 'D:\erpweb\ososerp\Web\node_modules\ngx-material-timepicker\fesm2015' 

Things I have tried so far,

  1. Deleted the node_modules folder and package-lock.json from the project.
  2. Executed npm cache clean --force.
  3. Deleted the 'luxon' folder from the global TypeScript directory.
  4. Ran npm i to reinstall dependencies.

How can I resolve this,

like image 316
Sachith Wickramaarachchi Avatar asked Jul 17 '26 07:07

Sachith Wickramaarachchi


1 Answers

I was abled to solve it by doing these steps,

npm install luxon moment

Then installed the required dev dependencies:

npm install --save-dev @types/lodash @types/luxon
like image 66
Sachith Wickramaarachchi Avatar answered Jul 20 '26 02:07

Sachith Wickramaarachchi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!