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

Can't import library from tools (generator) #4801

Closed
jase88 opened this issue Feb 16, 2021 · 2 comments
Closed

Can't import library from tools (generator) #4801

jase88 opened this issue Feb 16, 2021 · 2 comments

Comments

@jase88
Copy link

jase88 commented Feb 16, 2021

Current Behavior

If I import a library from my workspace (e.g. @my-workspace/utils) on my generator

my-generator.ts

import { Tree } from '@nrwl/devkit';
import { sayHello } from '@my-workspace/utils';

export default async function (host: Tree, schema: any) {
  console.log(sayHello(schema.name));
}

I get an error:

Cannot find module 'C:\src\nx-pnpm\dist\out-tsc\generators\my-generator'
Require stack:
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\shared\workspace.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\commands\generate.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\index.js

Expected Behavior

I'm able to import a library to a generator without receiving an error

Steps to Reproduce

Failure Logs

nx workspace-generator my-generator test --verbose

Warning: Fell back to using 'fs' to identify tools/tsconfig.generated.json as deleted. Please open an issue at https://github.com/nrwl/nx so we can investigate.
Cannot find module 'C:\src\nx-pnpm\dist\out-tsc\generators\my-generator'
Require stack:
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\shared\workspace.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\commands\generate.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\index.js
Error: Cannot find module 'C:\src\nx-pnpm\dist\out-tsc\generators\my-generator'
Require stack:
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\shared\workspace.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\commands\generate.js
- C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at Module.require (C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\compat\compat.js:7:40)
    at require (node:internal/modules/cjs/helpers:92:18)
    at implementationFactory (C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\shared\workspace.js:87:32)
    at Object.<anonymous> (C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\@nrwl\tao\11.2.12\node_modules\@nrwl\tao\src\commands\generate.js:171:40)
    at Generator.next (<anonymous>)
    at fulfilled (C:\src\nx-pnpm\node_modules\.pnpm\registry.npmjs.org\tslib\2.1.0\node_modules\tslib\tslib.js:114:62)

Environment

 Node : 15.8.0
  OS   : win32 x64
  pnpm : 4.7.1

  nx : Not Found
  @nrwl/angular : 11.2.12
  @nrwl/cli : 11.2.12
  @nrwl/cypress : 11.2.12
  @nrwl/devkit : 11.2.12
  @nrwl/eslint-plugin-nx : 11.2.12
  @nrwl/express : Not Found
  @nrwl/jest : 11.2.12
  @nrwl/linter : 11.2.12
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 11.2.12
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.2.12
  @nrwl/web : Not Found
  @nrwl/workspace : 11.2.12
  typescript : 4.0.7
@FrozenPandaz
Copy link
Collaborator

#2536 has more details about this issue.

It's still open and we will look at it when we get a chance.

Closing this issue as a duplicate of #2536.

@github-actions
Copy link

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 Mar 24, 2023
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

2 participants