# Alias paths in tsconfig.json and webpack not working

**URL:** <https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929>\
**Category:** ionic-v3\
**Created:** [December 20, 2017, 5:51am UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929 "2017-12-20T05:51:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johneast](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@johneast](https://forum.ionicframework.com/u/johneast)\
**Post date:** [December 20, 2017, 5:51am UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929/1 "2017-12-20T05:51:04Z")

</div>

For a project that requires shared lib code between several apps, consider the following directory structor

|-proj/  
|–apps/  
|—my-mobile-app/  
|----src/  
|—my-electron-app/  
|–libs/  
|—core/  
|—services/

I would like to use modules in proj/libs/\* inside my ionic app which is in proj/apps/my-mobile-app

I don’t want to publish my libs as npm packages because a) these are never going to be public, b) the workflow of changing code and publishing to a local server in order to get the change into the app is too slow. I’ve tried linking modules but because the libs themselves depend on angular and rxjs it all gets into a bit of a mess with multiple versions of angular installed and Http not being provided etc etc

I’ve tried following the instructions from the topic [Tsconfig.json modifications not working](https://forum.ionicframework.com/t/tsconfig-json-modifications-not-working/72098)

I’ve modified the tsconfig.json to include the following:

```auto
"baseUrl": ".",
"paths": {
  "@mylibs/*":[
    "../../libs/*"
  ]
}

```

and also followed the advice from the original post to alter the web pack config like

```auto
const path = require('path');
const webpackDefault = require('@ionic/app-scripts/config/webpack.config');
const webpackMerge = require('webpack-merge');

const customConfig = {
  resolve: {
    alias: {
      '@mylibs': path.resolve('../../libs')
    }
  }
};

module.exports = webpackMerge(webpackDefault, customConfig);

```

The project will compile when I run `ionic serve` but when I go to the browse I’m given a RuntimeError saying cannot find module `@mylibs/services`

I’m using ionic v3.19.0

Also, for bonus points, what I’d ideally like long term is to have one node\_modules folder in the root, and scripts in the root that can be used to build and serve the individual apps. I know I can do this with angular, is this possible with ionic?

Any help would be greatly appreciated.

Many thanks

---

<div class="post-metadata">

**Author:** ![robinyo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/robinyo/32/115964_2.png) [@robinyo](https://forum.ionicframework.com/u/robinyo)\
**Post date:** [December 20, 2017, 6:21am UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929/2 "2017-12-20T06:21:17Z")

</div>

See: [https://robferguson.org/blog/2017/11/22/working-with-typescript-webpack-and-ionic-3/](https://robferguson.org/blog/2017/11/22/working-with-typescript-webpack-and-ionic-3/)

### Resources:

- GitHub: [Easy to use environment variables for Ionic 3](https://github.com/gshigeto/ionic-environment-variables)
- GitHub: [Ionic CLI - Issue 1205 - Environment variable configuration](https://github.com/ionic-team/ionic-cli/issues/1205)
- TypeScript docs: [tsconfig.json  
 ](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
- webpack docs: [webpack.config.js](https://webpack.js.org/concepts/configuration/)

---

<div class="post-metadata">

**Author:** ![NoelDeMartin](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@NoelDeMartin](https://forum.ionicframework.com/u/NoelDeMartin)\
**Post date:** [December 20, 2017, 6:59am UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929/3 "2017-12-20T06:59:29Z")

</div>

You can also find the solution on this github issue: [https://github.com/ionic-team/ionic-cli/issues/1809](https://github.com/ionic-team/ionic-cli/issues/1809)

---

<div class="post-metadata">

**Author:** ![johneast](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@johneast](https://forum.ionicframework.com/u/johneast)\
**Post date:** [December 20, 2017, 2:46pm UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929/4 "2017-12-20T14:46:57Z")

</div>

Thanks.

That solved it for me. I think my webpack config was wrong, and I was also missing the ‘source\_map’ reference in the package.json config

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:58pm UTC](https://forum.ionicframework.com/t/alias-paths-in-tsconfig-json-and-webpack-not-working/115929/5 "2021-07-19T21:58:01Z")

</div>

Closed on July 19, 2021, 9:58pm UTC


