Nx: Error to execute: migration-v10-missing-injectable

Created on 3 Aug 2020  路  5Comments  路  Source: nrwl/nx

Current Behavior

The command nx migrate --run-migrations=migrations.json is giving me the error:

Could not find any tsconfig file. Cannot add the "@Injectable" decorator to providers which don't have that decorator set.
/home/temporin/workspace/builders/node_modules/yargs/yargs.js:1109
      else throw err
           ^

Error: Command failed: ./node_modules/.bin/tao migrate --run-migrations=migrations.json
    at checkExecSyncError (child_process.js:629:11)
    at Object.execSync (child_process.js:666:13)
    at Object.exports.commandsObject.yargs.usage.command.command.command.command.command.command.command.command.command.command.command.command.command.command.command.alias.command.command.command [as handler] (/home/temporin/workspace/builders/node_modules/@nrwl/workspace/src/command-line/nx-commands.js:77:21)
    at Object.runCommand (/home/temporin/workspace/builders/node_modules/yargs/lib/command.js:235:44)
    at Object.parseArgs [as _parseArgs] (/home/temporin/workspace/builders/node_modules/yargs/yargs.js:1022:30)
    at Object.get [as argv] (/home/temporin/workspace/builders/node_modules/yargs/yargs.js:965:21)
    at Object.initLocal (/home/temporin/workspace/builders/node_modules/@nrwl/cli/lib/init-local.js:24:13)
    at Object.<anonymous> (/home/temporin/workspace/builders/node_modules/@nrwl/cli/bin/nx.js:12:18)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

After I talk with @devversion about this problem, I realize that Angular migration only checks for angular.json and .angular.json files to find the projects inside the workspace.

Since NX workspace is defined on workspace.json, the migration can't find any project to migrate.
I put the logs from the execution in the logs section.

Expected Behavior

Migrate

Steps to Reproduce

A project with two or more apps and a few libraries

Logs

defaultWorkspceConfigPath - [ '/angular.json', '/.angular.json' ]

```bash
getProjectTsConfigPaths: tree param - HostTree {
_backend:
ScopedHost {
_delegate: NodeJsSyncHost {},
_root: '/home/temporin/workspace/builders' },
_id: -1,
_ancestry: Set {},
_dirCache: Map {},
_record:
CordHost {
_cache: Map { '/' => },
_watchers: Map {},
_back: SafeReadonlyHost { _delegate: [ScopedHost] },
_filesToCreate: Set {},
_filesToRename: Map {},
_filesToRenameRevert: Map {},
_filesToDelete: Set {},
_filesToOverwrite: Set {} },
_recordSync:
SyncDelegateHost {
_delegate:
CordHost {
_cache: [Map],
_watchers: Map {},
_back: [SafeReadonlyHost],
_filesToCreate: Set {},
_filesToRename: Map {},
_filesToRenameRevert: Map {},
_filesToDelete: Set {},
_filesToOverwrite: Set {} } } }

```bash
getProjectTsConfigPaths: workspace var - null

Environment

nx : Not Found
@nrwl/angular : 10.0.7
@nrwl/cli : 10.0.7
@nrwl/cypress : 10.0.7
@nrwl/eslint-plugin-nx : 10.0.7
@nrwl/express : Not Found
@nrwl/jest : 10.0.7
@nrwl/linter : 10.0.7
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 10.0.7
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 10.0.7
@nrwl/web : Not Found
@nrwl/workspace : 10.0.7
typescript : 3.9.7

angular bug

Most helpful comment

Just leaving an update here, but we are looking into this issue for a more permanent fix. The workaround mentioned above works for now.

All 5 comments

I have the same issue. Monkey patching the angular/core file to add workspace.json helped me to the next migration.

File : node_modules/@angular/core/schematics/utils/project_tsconfig_paths.js

/** Name of the default Angular CLI workspace configuration files. */
    const defaultWorkspaceConfigPaths = ['/angular.json', '/.angular.json', '/workspace.json'];

Next error:

Running migration @nrwl/angular:update-10-0-0
    Updating @angular/cli to 10.0.0


Error: Cannot find module 'node_modules/@angular/cli/bin/ng
@angular/cli migration failed, see above.

Of course I have no ng available when I rely on the Nx CLI. I can't believe this slipped through Nx's testing or that this fails for everyone. The renamed workspace is something so common it must be handled by Nx for every past Angular migration. Is something else failing in our workspaces?

Running into the same issue.

I worked around it by symlinking workspace.json to angular.json:

ln -s workspace.json angular.json

@brandonroberts I got a repro. Can't make the repository public as it's not open source, but I can share it with you if that helps.

Does anyone have a solution? Is it to do that solution mentioned by @beeman then install separately the @angular/cli to avoid the issue described by @georgiee?

I didn't install the Angular CLI. What I did do though, is after the first failure, I rolled back any local changes the upgrade made, created the symlink and ran the upgrade again. Not sure if that made the difference but it's what worked for me.

Just leaving an update here, but we are looking into this issue for a more permanent fix. The workaround mentioned above works for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jon301 picture jon301  路  3Comments

olakara picture olakara  路  3Comments

joelmuskwe picture joelmuskwe  路  3Comments

zpydee picture zpydee  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments