I'm currently working on a proof of concept for a basic monorepo application. To structure my packages, I've decided to use Yarn Workspaces
instead of Lerna as it seems more suitable for my needs.
One of the packages in my setup is shared
, which is meant to be used by both the frontend and backend. While I have successfully integrated it with the frontend using NextJS along with the NPM library next-transpile-module, I'm facing challenges with the backend. Despite searching online extensively, I couldn't find any relevant information or resources.
When attempting to start the API, I encounter the following error:
/Users/Alfonso/git/taurus/packages/shared/dist/index.js:1
export var PRODUCT_NAME = "ACME";
^^^^^^
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.<anonymous> (/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)
This error, similar to the one encountered in the client
package, was resolved using the next-transpile-module
NPM library. Hence, it appears to be related to transpilation issues, but I'm unsure how to proceed further!