Quantcast
Channel: Active questions tagged require - Stack Overflow
Viewing all articles
Browse latest Browse all 166

How to have aliases with nodejs import

$
0
0

I have a project using node.js v16, and more and more npm libs are not anymore compatible with require, and need to be used with import.

Until now i was using package.json to have my root directory as alias

  // package.json"dependencies": {"~src": "file:.",  }

And in my source code

const someCode = require('~src/absolute/path/someCode');

This is not working with import, and with tests i made, i haven't found any solution to make it works with import.

Have you already met that kind of problem ? And found a solution about it ?


Viewing all articles
Browse latest Browse all 166

Trending Articles