title: Lerna + TypeScript + npm: How do I properly setup the config so that @projectName/package paths through the dist directory?
body: <p>I'm trying to get my project setup as a monorepo but I'm running into an annoying issue of pathing with TypeScript &amp; Lerna.</p>
  
  <p>I have 2 react projects, an API, and a core project which warehouses my domain model &amp; typescript definitions. For right now, I need to be able to use the code from the core in my API and the definitions across my 2 react projects.</p>
  
  <p>The issue that I'm running into that is that I have to path from the root of each package. For example,  <code>@projectName/core/src/models/myModel</code> instead of <code>@projectName/core/models/myModel</code>. The <code>dist</code> directory does not contain that structure and that's what I'm aiming to import.</p>
  
  <p>I found a couple of articles suggesting how to set it up but I'm still running into issues and not sure where I'm going wrong.</p>
  
  <p>I'm just focusing right now on exporting <code>@projectName/core</code>.</p>
  
  <h3>./tsconfig.json</h3>
  
  <pre><code>{
    "exclude": ["node_modules", "dist"],
    "compilerOptions": {
      "baseUrl": ".",
      "sourceMap": true,
      "composite": true,
      "declaration": true,
      "paths": {
        "@projectName/core": ["packages/core/src"],
        "@projectName/api": ["packages/api/src"],
        "@projectName/admin": ["packages/admin/src"],
        "@projectName/client": ["packages/client"]
      }
    }
  }
  </code></pre>
  
  <h3>./package.json</h3>
  
  <pre><code>{
    "name": "projectName",
    "private": true,
    "devDependencies": {
      "lerna": "^3.20.2",
      "typescript": "^3.8.3"
    }
  }
  </code></pre>
  
  <h3>./packages/core/tsconfig.json</h3>
  
  <pre><code>{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
      "esModuleInterop": true,
      "allowSyntheticDefaultImports": true,
      "lib": ["ES2019"],
      "module": "commonjs",
      "target": "ES2019",
      "strict": true,
      "resolveJsonModule": true,
      "moduleResolution": "node",
      "sourceMap": true,
      "outDir": "./dist",
      "rootDir": "./src"
    },
  
    "include": ["src/**/*"]
  }
  </code></pre>
  
  <h3>./packages/core/package.json</h3>
  
  <pre><code>{
    "name": "@projectName/core",
    "version": "0.0.1",
    "private": true,
    "directories": {
      "lib": "dist",
      "test": "tests"
    },
    "files": [
      "dist"
    ],
    "scripts": {
      "build": "npm run clean &amp;&amp; npm run compile",
      "clean": "rm -rf ./dist",
      "compile": "tsc"
    },
    "dependencies": {
    },
    "devDependencies": {
      "typescript": "^3.8.3",
      "webpack": "^4.43.0",
    }
  }
  </code></pre>
  
  <h3>./packages/api/tsconfig.json</h3>
  
  <pre><code>{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
      "esModuleInterop": true,
      "allowSyntheticDefaultImports": true,
      "lib": ["ES2019"],
      "module": "commonjs",
      "target": "ES2019",
      "strict": true,
      "resolveJsonModule": true,
      "moduleResolution": "node",
      "sourceMap": true,
      "outDir": "dist"
    },
    "include": ["src/**/*"]
  }
  </code></pre>
  
  <h3>./packages/api/package.json</h3>
  
  <pre><code>{
    "name": "@projectName/api",
    "version": "0.0.1",
    "description": "api",
    "files": [
      "dist"
    ],
    "main": "dist/server.js",
    "scripts": {
    },
    "dependencies": {
      "@packageName/core": "^0.0.1",
    },
    "devDependencies": {
      "typescript": "^3.8.3",
      "webpack": "^4.43.0",
      "webpack-node-externals": "^1.7.2"
    },
    "private": true
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jHNYE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHNYE.png" alt="path"></a></p>
  
  <p>I removed dependencies from the above to keep it readable. </p>
  
  <p>These settings were added to <code>./tsconfig.json</code> in an attempt to get this to work: </p>
  
  <pre><code>    "composite": true,
      "declaration": true
  </code></pre>
  
  <p>Any help would be much appreciated. Thanks!</p>