Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishable lib - import not found #18349

Closed
4 tasks
rrios-dev opened this issue Jul 27, 2023 · 4 comments
Closed
4 tasks

publishable lib - import not found #18349

rrios-dev opened this issue Jul 27, 2023 · 4 comments

Comments

@rrios-dev
Copy link

Current Behavior

I have an integrated monorepo with some publishable libraries that have dependencies between them, when I try to run affected:build in github action some dependencies declared as peerDependencies are not built before the dependent libraries, so I get an error like this cannot find module '@my-org/package-lib' or its corresponding type declarations..

I've tried applying different solutions but they don't work correctly, my current command in the github action is: npx nx affected -t build --parallel=3 --with-deps.

In each package.json of the libraries I have declared the modules as peerDependencies.

Can someone help me with this problem, I haven't found any information about it.

Expected Behavior

Affected can parse all dependencies and detect those that are in the monorepo by first running the build of the dependencies.

GitHub Repo

No response

Steps to Reproduce

  1. Create two publishable libraries 'a' and 'b'
  2. Make a dependency from 'b' to 'a'
  3. Create a github workflow with affected:build
  4. When libraries 'b' or 'a' have modifications, first build b and then a.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : darwin-x64
   yarn   : 1.17.3
   
   nx                 : 16.5.5
   @nx/js             : 16.5.5
   @nx/jest           : 16.5.5
   @nx/linter         : 16.5.5
   @nx/workspace      : 16.5.5
   @nx/cypress        : 16.5.5
   @nx/devkit         : 16.5.5
   @nx/eslint-plugin  : 16.5.5
   @nx/next           : 16.5.5
   @nx/plugin         : 16.5.5
   @nx/react          : 16.5.5
   @nx/rollup         : 16.5.5
   @nx/storybook      : 16.5.5
   @nrwl/tao          : 16.5.5
   @nx/web            : 16.5.5
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @nxkit/playwright : 3.0.2
   ---------------------------------------
   Local workspace plugins:
         @deveahub/react-formik-control
         @deveahub/workspace-extensions
         @deveahub/react-error-message
         @deveahub/react-form-control
         @deveahub/playwright-toolbox
         @deveahub/react-alert-modal
         @deveahub/react-hover-card
         @deveahub/react-typography
         @deveahub/react-accordion
         @deveahub/react-separator
         @deveahub/react-checkbox
         @deveahub/react-popover
         @deveahub/react-spinner
         @deveahub/react-avatar
         @deveahub/react-button
         @deveahub/styled
         @deveahub/react-badge
         @deveahub/react-input
         @deveahub/react-label
         @deveahub/react-modal
         @deveahub/react-radio
         @deveahub/react-box

Failure Logs

Run npx nx affected -t build --parallel=3 --with-deps
  

 >  NX   No explicit --base argument provided, but found environment variable NX_BASE so using its value as the affected base: 25dbf74f12df597bfaf36104c614019b8d64f27a


 >  NX   No explicit --head argument provided, but found environment variable NX_HEAD so using its value as the affected head: 6442ae3649a1536f0485e0566f67335d2027c7ba


 >  NX   Running target build for 20 projects:

    - ui-kit-react-form-control
    - ui-kit-react-formik-control
    - ui-kit-react-error-message
    - ui-kit-react-alert-modal
    - ui-kit-react-typography
    - ui-kit-react-hover-card
    - ui-kit-react-separator
    - ui-kit-react-accordion
    - ui-kit-react-checkbox
    - ui-kit-react-spinner
    - ui-kit-react-popover
    - ui-kit-react-styled
    - ui-kit-react-avatar
    - ui-kit-react-button
    - ui-kit-react-badge
    - ui-kit-react-label
    - ui-kit-react-input
    - ui-kit-react-radio
    - ui-kit-react-modal
    - ui-kit-react-box
   
   With additional flags:
     --with-deps=true

 

> nx run ui-kit-react-box:build --with-deps

Bundling ui-kit-react-box...
Error during bundle: Error: packages/ui-kit/react/box/src/lib/box.ts:1:40 - error TS2307: Cannot find module '@deveahub/styled' or its corresponding type declarations.

1 import { ComponentProps, styled } from '@deveahub/styled';
                                         ~~~~~~~~~~~~~~~~~~

Bundle failed: ui-kit-react-box

> nx run ui-kit-react-styled:build --with-deps

Compiling TypeScript files for project "ui-kit-react-styled"...
Done compiling TypeScript files for project "ui-kit-react-styled".

> nx run ui-kit-react-error-message:build --with-deps

Bundling ui-kit-react-error-message...
  index.js 336 Bytes
⚡ Done in 7.16s

> nx run ui-kit-react-form-control:build --with-deps

Bundling ui-kit-react-form-control...
Error during bundle: Error: packages/ui-kit/react/form-control/src/lib/form-control.tsx:1:23 - error TS2307: Cannot find module '@deveahub/react-box' or its corresponding type declarations.

1 import { Stack } from '@deveahub/react-box';
                        ~~~~~~~~~~~~~~~~~~~~~
packages/ui-kit/react/form-control/src/lib/form-control.tsx:3:23 - error TS2307: Cannot find module '@deveahub/react-label' or its corresponding type declarations.

3 import { Label } from '@deveahub/react-label';
                        ~~~~~~~~~~~~~~~~~~~~~~~

Bundle failed: ui-kit-react-form-control

> nx run ui-kit-react-label:build --with-deps

Bundling ui-kit-react-label...
  index.js 168 Bytes
⚡ Done in 6.22s

> nx run ui-kit-react-formik-control:build --with-deps

Bundling ui-kit-react-formik-control...
Error during bundle: Error: packages/ui-kit/react/formik-control/src/lib/formik-control.tsx:1:47 - error TS2307: Cannot find module '@deveahub/react-form-control' or its corresponding type declarations.

1 import { FormControlProps, FormControl } from '@deveahub/react-form-control';
                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bundle failed: ui-kit-react-formik-control

> nx run ui-kit-react-alert-modal:build --with-deps

Bundling ui-kit-react-alert-modal...
Error during bundle: Error: packages/ui-kit/react/alert-modal/src/lib/styles.ts:1:29 - error TS2307: Cannot find module '@deveahub/react-box' or its corresponding type declarations.

1 import { Flex, Stack } from '@deveahub/react-box';
                              ~~~~~~~~~~~~~~~~~~~~~

Bundle failed: ui-kit-react-alert-modal

> nx run ui-kit-react-typography:build --with-deps

Bundling ui-kit-react-typography...
  index.js 2.357 KB
⚡ Done in 6.93s

> nx run ui-kit-react-hover-card:build --with-deps

Bundling ui-kit-react-hover-card...
  index.js 3.785 KB
⚡ Done in 8.69s

> nx run ui-kit-react-accordion:build --with-deps

Bundling ui-kit-react-accordion...
  index.js 1.265 KB
⚡ Done in 6.38s

> nx run ui-kit-react-separator:build --with-deps

Bundling ui-kit-react-separator...
  index.js 1.477 KB
⚡ Done in 6.66s

> nx run ui-kit-react-checkbox:build --with-deps

Bundling ui-kit-react-checkbox...
  index.js 4.188 KB
⚡ Done in 7.40s

> nx run ui-kit-react-spinner:build --with-deps

Bundling ui-kit-react-spinner...
  index.js 931 Bytes
⚡ Done in 6.21s

> nx run ui-kit-react-popover:build --with-deps

Bundling ui-kit-react-popover...
  index.js 5.162 KB
⚡ Done in 9.02s

> nx run ui-kit-react-button:build --with-deps

Bundling ui-kit-react-button...
  index.js 2.924 KB
⚡ Done in 8.03s

> nx run ui-kit-react-input:build --with-deps

Bundling ui-kit-react-input...
  index.js 3.498 KB
⚡ Done in 7.94s

> nx run ui-kit-react-radio:build --with-deps

Bundling ui-kit-react-radio...
  index.js 1.503 KB
⚡ Done in 5.01s

> nx run ui-kit-react-modal:build --with-deps

Bundling ui-kit-react-modal...
Error during bundle: Error: packages/ui-kit/react/modal/src/lib/styles.ts:1:29 - error TS2307: Cannot find module '@deveahub/react-box' or its corresponding type declarations.

1 import { Flex, Stack } from '@deveahub/react-box';
                              ~~~~~~~~~~~~~~~~~~~~~

Bundle failed: ui-kit-react-modal

> nx run ui-kit-react-badge:build --with-deps

Bundling ui-kit-react-badge...
  index.js 95 Bytes
⚡ Done in 3.86s

> nx run ui-kit-react-avatar:build --with-deps

Bundling ui-kit-react-avatar...
  index.js 3.345 KB
⚡ Done in 236.34s

 

 >  NX   Running target build for 20 projects failed

   Failed tasks:
   
   - ui-kit-react-box:build
   - ui-kit-react-form-control:build
   - ui-kit-react-formik-control:build
   - ui-kit-react-alert-modal:build
   - ui-kit-react-modal:build

Error: Process completed with exit code 1.

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@vincent-thomas
Copy link

Have this issue as well. But also this type of error
error TS6059: File 'C:/Users/vincent/P/apps/things/libs/format/src/lib/buffer.ts' is not under 'rootDir' 'libs/cryptography'. 'rootDir' is expected to contain all source files.

@mandarini
Copy link
Member

mandarini commented Oct 25, 2023

@vincent-thomas and anyone else, is it possible that your build target names (of two interdependent libs) are different? This bug can appear if you are importing one buildable lib into the other, and the build target names are different. I am not saying that's the issue you are facing, I'm just saying that this issue can appear under this circumstance.

related: #11289

For anyone having that error, solution: #17798 (comment)

Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

Copy link

github-actions bot commented Jun 8, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants