# serverless cli package can't resolve nx monorepo imports

**URL:** <https://forum.serverless.com/t/serverless-cli-package-cant-resolve-nx-monorepo-imports/18191>\
**Category:** Serverless Framework\
**Created:** [January 12, 2023, 8:55pm UTC](https://forum.serverless.com/t/serverless-cli-package-cant-resolve-nx-monorepo-imports/18191 "2023-01-12T20:55:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldylucks](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/goldylucks/32/7246_2.png) [@goldylucks](https://forum.serverless.com/u/goldylucks)\
**Post date:** [January 12, 2023, 8:55pm UTC](https://forum.serverless.com/t/serverless-cli-package-cant-resolve-nx-monorepo-imports/18191/1 "2023-01-12T20:55:34Z")

</div>

I have many apps consuming many libraries in a monorepo, and everything works except the `$ sls package` command.

It breaks because it can’t resolve the imports I define in `tsconfig`’s.

This is my structure:

```auto
- tsconfig.base.json
- apps
  - serverless
    - tsconfig.json
  - app2
    - tsconfig.json
- libs
  - lib1
    - tsconfig.json
  - lib2
    - tsconfig.json

```

```auto
// tsconfig.base.json
{
  "compileOnSave": false,
  "compilerOptions": {
    "noPropertyAccessFromIndexSignature": false,
    "resolveJsonModule": true,
    "rootDir": ".",
    "esModuleInterop": true,
    "sourceMap": true,
    "noImplicitReturns": false,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "paths": {
      "~/*": ["./*"],
      "@nx/lib1": ["../../../libs/lib1/src/index.ts"],
      "@nx/lib2": ["../../../libs/lib2/src/index.ts"]
    },
    "types": ["node", "jest"]
  },
  "exclude": ["node_modules", "tmp"]
}

```

```auto
// apps/serverless/tsconfig.json
{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "baseUrl": "src"
  },
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}

```

```auto
// apps/serverless/tsconfig.app.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "module": "commonjs",
    "types": ["node"]
  },
  "exclude": ["jest.config.ts", " **/*.spec.ts", "** /*.test.ts"],
  "include": ["**/*.ts"]
}

```

like I said everything works, except `$ sls package` which produces many errors like:

```auto
✘ [ERROR] Could not resolve "@nx/constants"
You can mark the path "@nx/constants" as external to exclude it from the bundle, which will remove this error.

```

any ideas what I’m missing here?
