ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.73k stars 68 forks source link

How to use the modules-alias with lerna ,it is unused in a lerna project. #120

Open radiorz opened 2 years ago

radiorz commented 2 years ago

I use lerna to manage my project.and the nodejs server is one of packages. I run the script on the root

npm run my-server dev

and it return a error :

Error: Cannot find module '@/...'
brillout commented 2 years ago

Same problem here. Did someone find a solution?

flyingbirdhub commented 2 years ago

For now, you can use like that:

`import { init } from 'module-alias;

init({ base: 'Path to your package.json' }); `

do not use import 'module-alias/register, as said here https://github.com/ilearnio/module-alias#using-within-another-npm-package