-1

I'm new in Typescript and building Typescript library, but I got a problem:

  1. I created a library say, @my-lib/my-first-lib.
  2. I created another library say, @my-lib/my-second-lib which depends on @my-lib/my-first-lib.
  3. I would like to use the @my-lib/my-second-lib in other project, say, my-project however, I got the following error message when I tried to compile:
Module not found: Error: Can't resolve '@my-lib/my-first-lib/lib-es2015' in '/Some/path/to/my-project/node_modules/@my-lib/my-second-lib/lib-es2015/file-name-using-first'

The tsconfig.json is as follow:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": true,
    "module": "es2015",
    "target": "es2015",
    "lib": ["es2015", "dom"],
    "declaration": true,
    "outDir": "lib-es2015",
    "sourceMap": true,
    "strictNullChecks": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "skipLibCheck": true,
  },
  "files": ["src/index.ts"],
  "exclude": [
    "node_modules"
  ],
  "include": [
    "src/**/*"
  ]
}

All the libraries are compiled by following command:

tsc -p tsconfig.json

If I include @my-lib/my-first-lib as dependency in the package.json file of my-project it works fine. But I think this is not the answer, because I have to include thousand of the dependencies if @my-lib/my-second-lib has thousand of dependencies.

Please, somebody show me the way.

1 Answer 1

0

Moving @my-lib/my-first-lib from "devDependencies" to "dependencies" in package.json file of @my-lib/my-second-lib solves the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.