title: How to do code sharing in NestJS through Yarn Workspaces
body: <p>I'm trying to do a proof of concept for a simple monorepo application. I decided to just use <code>Yarn Workspaces</code> (I think <a href="https://lerna.js.org" rel="nofollow noreferrer">Lerna</a> maybe here is overkill) to set up my package architecture.</p>
  <p>I have a <code>shared</code> package that I'm using to share code with the frontend and the backend. I successfully achieved to make it works for the frontend (As I'm using <a href="https://nextjs.org" rel="nofollow noreferrer">NextJS</a> in the frontend there was already a NPM library named <a href="https://www.npmjs.com/package/next-transpile-modules" rel="nofollow noreferrer">next-transpile-module</a> to get everything running up smoothly) but now, I'm stuck at the backend, and I'm not sure if it's even possible because I couldn't find information on Google.</p>
  <p>Here's the error that it's throwing up when I try to start the API:</p>
  <pre><code>/Users/Alfonso/git/taurus/packages/shared/dist/index.js:1
  export var PRODUCT_NAME = &quot;ACME&quot;;
  ^^^^^^
  
  SyntaxError: Unexpected token 'export'
      at wrapSafe (internal/modules/cjs/loader.js:1054:16)
      at Module._compile (internal/modules/cjs/loader.js:1102:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
      at Module.load (internal/modules/cjs/loader.js:986:32)
      at Function.Module._load (internal/modules/cjs/loader.js:879:14)
      at Module.require (internal/modules/cjs/loader.js:1026:19)
      at require (internal/modules/cjs/helpers.js:72:18)
      at Object.&lt;anonymous&gt; (/Users/Alfonso/git/taurus/packages/api/dist/app.service.js:11:18)
      at Module._compile (internal/modules/cjs/loader.js:1138:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
  </code></pre>
  <p>It's exactly the same error (<code>Unexpected token 'export'</code>) that I was getting in the <code>client</code> package, but as I mentioned, that NPM lib named <code>next-transpile-module</code> fixed it.. so it should be something related to transpilation but I have no idea! :)</p>