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

Angular 12 Schematics throws error: Cannot find module 'bluebird' #20685

Closed
1 task done
mraible opened this issue May 3, 2021 · 8 comments
Closed
1 task done

Angular 12 Schematics throws error: Cannot find module 'bluebird' #20685

mraible opened this issue May 3, 2021 · 8 comments

Comments

@mraible
Copy link
Contributor

mraible commented May 3, 2021

🐞 Bug report

Command (mark with an x)

  • add

Is this a regression?

Yes.

Description

I created OktaDev Schematics as a way to add authentication with Okta to new apps that are created with a framework's respective CLI (e.g., Angular CLI, Create React App, Vue CLI, etc.).

Yesterday, I discovered it doesn't work with Angular CLI v12 RC1.

$ ng add @oktadev/schematics
ℹ Using package manager: npm
✔ Found compatible package version: @oktadev/[email protected].
✔ Package information loaded.

The package @oktadev/[email protected] will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
? What is your OIDC app's issuer URL? foo
? What is your OIDC app's client ID? bar
Cannot find module 'bluebird'
Require stack:
- /Users/mraible/foo/node_modules/@schematics/update/node_modules/pacote/extract.js
- /Users/mraible/foo/node_modules/@schematics/update/node_modules/pacote/index.js
- /Users/mraible/foo/node_modules/@schematics/update/update/npm.js
- /Users/mraible/foo/node_modules/schematics-utilities/dist/package_update/npm.js
- /Users/mraible/foo/node_modules/schematics-utilities/dist/package_update/index.js
- /Users/mraible/foo/node_modules/schematics-utilities/dist/index.js
- /Users/mraible/foo/node_modules/@oktadev/schematics/src/add-auth/index.js
- /Users/mraible/foo/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/mraible/foo/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/mraible/foo/node_modules/@angular/cli/utilities/json-schema.js
- /Users/mraible/foo/node_modules/@angular/cli/models/command-runner.js
- /Users/mraible/foo/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng

🔬 Minimal Reproduction

Steps to reproduce:

npm i -g @angular/cli@next
ng new foo --routing --style css
ng add @oktadev/schematics

It doesn't happen if I use Angular CLI v11.2.11.

$ ng add @oktadev/schematics
ℹ Using package manager: npm
✔ Found compatible package version: @oktadev/[email protected].
✔ Package information loaded.
✔ Package successfully installed.
? What is your OIDC app's issuer URL? foo
? What is your OIDC app's client ID? bar
            ✅️ Added '@okta/okta-angular' into dependencies
            🔍 Installing packages...
CREATE src/app/auth-routing.module.ts (1174 bytes)
CREATE src/app/home/home.component.html (186 bytes)
CREATE src/app/home/home.component.spec.ts (1027 bytes)
CREATE src/app/home/home.component.ts (638 bytes)
CREATE src/app/home/home.component.css (0 bytes)
CREATE src/app/shared/okta/auth.interceptor.ts (1019 bytes)
UPDATE src/app/app.module.ts (475 bytes)
UPDATE package.json (1276 bytes)
UPDATE src/app/app.component.spec.ts (1386 bytes)
UPDATE src/app/app.component.ts (603 bytes)
✔ Packages installed successfully.
Execution time: 19 s.

🔥 Exception or Error


Cannot find module 'bluebird'
Require stack:
- /Users/mraible/foo/node_modules/@schematics/update/node_modules/pacote/extract.js
- /Users/mraible/foo/node_modules/@schematics/update/node_modules/pacote/index.js

🌍 Your Environment


Angular CLI: 12.0.0-rc.1
Node: 14.16.1
Package Manager: npm 7.11.2
OS: darwin x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1200.0-rc.1 (cli-only)
@angular-devkit/core         12.0.0-rc.1 (cli-only)
@angular-devkit/schematics   12.0.0-rc.1 (cli-only)
@schematics/angular          12.0.0-rc.1 (cli-only)

Anything else relevant?

I commented here yesterday, but figured it might be better to open a new issue.

/cc @mgechev

@clydin
Copy link
Member

clydin commented May 3, 2021

From the log output, it appears that the schematics-utilities package may not be compatible with v12.
It seems to be depending on older, unsupported versions of the Angular packages.
From the version 2.0.3 package.json:

  "dependencies": {
    "@angular-devkit/core": "^8.3.8",
    "@angular-devkit/schematics": "^8.3.8",
    "@schematics/angular": "^8.3.8",
    "@schematics/update": "^0.803.8",
    "rxjs": "^6.4.0",
    "typescript": "^3.6.3"
  },

@mraible
Copy link
Contributor Author

mraible commented May 3, 2021

Adding @nitayneeman to this thread since they're the maintainer of schematics-utilities.

Nitay, do you have a plan to make things work with Angular 12?

@nitayneeman
Copy link

@mraible There is a plan to upgrade the dependencies to v10 but just bumping them isn't so straightforward since there were breaking changes.

It can be considered to align with v12 directly but again depending on the amount of breaking changes/complexity they bring up. Probably will happen in the next major version of schematic-utilities.

Honestly my capacity is pretty limited, so any help would be much appreciated.

@alan-agius4
Copy link
Collaborator

Closing this issue. Since this is not actionable by the Angular tooling team.

@mraible
Copy link
Contributor Author

mraible commented May 4, 2021

@nitayneeman Thanks for your honesty. I think I can remove schematics-utilities and replace it with @angular/cdk. See oktadev/schematics#569 for more info.

@alan-agius4
Copy link
Collaborator

@mraible,

Please be aware that both of the below entrypoints are private APIs and can be changed or removed without warning at anytime include private versions.

Moreover, the CDK is not meant to be used in Schematics. It’s intention is to be used for component development. In this case you are just using a private utility function that is using in their schematics.

import { addPackageJsonDependency, NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
import { addModuleImportToModule } from '@angular/cdk/schematics';

@mraible
Copy link
Contributor Author

mraible commented May 13, 2021

@alan-agius4 Thanks for the advice. I believe schematics-utilities just copies those classes and freezes them in a sense. Hopefully, with OktaDev's Schematics robust CI process, I'll be notified when the CDK changes anything. In the meantime, are you aware of any public utilities that make it easy to add a module import to a module?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants