question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding @ngwl/workspace fails is config files are not in root

See original GitHub issue

Expected Behavior

ng add @nrwl/workspace should work to add Nx to existing Angular CLI project.

Current Behavior

If config files such as tsconfig.app.json are stored in a subfolder such as src, the add will fail.

Failure Information (for bugs)

The failure is happening because the ng-add schematic extracts the locations of the config files from angular.json, it runs them through a getFilename() function that discards the rest of the path: https://github.com/nrwl/nx/blob/master/packages/workspace/src/schematics/ng-add/ng-add.ts#L381

Steps to Reproduce

  1. ng new nx-test
  2. cd nx-test
  3. mv tsconfig.app.json src
  4. Edit angular.json and update the "tsConfig" property of the project to the new path.
  5. ng add @nrwl/workspace.

Context

Please provide any relevant information about your setup:

Nx: 8.1 Angular CLI: 8

Failure Logs

    Renamed karma.conf.js -> apps/nx-test/karma.conf.js
    Path: tsconfig.app.json does not exist
    Renamed tsconfig.spec.json -> apps/nx-test/tsconfig.spec.json
    Renamed src -> apps/nx-test/src
    Renamed e2e -> apps/nx-test-e2e
ENOENT: no such file or directory, open 'apps/nx-test/tsconfig.app.json'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
studdscommented, Jul 26, 2019

As a workaround, I needed to:

  • mv e2e/protractor.conf.js e2e/tsconfig.e2e.json src/tsconfig* src/karma.conf.js .
  • Change the paths above in angular.json
  • mv .prettierignore .prettierignore.bak (as the schematic assumes this doesn’t exist)
  • mv .prettierrc.json .prettierrc.json.bak (ditto)

The schematic also chokes if any of the target directories exist, which is a minor annoyance when repeatedly running the commands and then resetting the changes (which removes the files but not the directories).

In addition, a few other problems I encountered, for posterity and / or very keen maintainers:

  • proxyConfig path in angular.json wasn’t update (which already existed in my app)
  • nx.json had a corrupted e2e project name: {{project}}-e2e-e2e
  • the e2e root path didn’t get updated in angular.json
  • the e2e project directory was incorrect: {{project}}-e2e-e2e
  • the apps/{{project}}/src/tslint.json wasn’t updated with the right extends (pointed to ../tslint.json instead of ../../../tslint.json
  • the e2e tsconfig wasn’t moved into the final directory (whereas the main app tsconfig was)
  • imports relative to the baseUrl in tsconfig.json were broken (understandable, but mentioning for completeness)
  • location of karma.conf.js changed, but basePath inside not changed to match
  • to get tests running, needed to move karma.conf.js and tsconfig.spec.json to the src directory (not sure why, or how to fix…)
0reactions
cguilhermefcommented, Aug 18, 2020

The workaround proposed by @studds is out of date for Angular 10. I’m trying to move files using exactly the same command mv e2e/protractor.conf.js e2e/tsconfig.e2e.json src/tsconfig* src/karma.conf.js ., but some file has different names.

I won’t create an empty project to migrate the whole code from the previous repository to a new one. Some suggestion?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building CI/CD pipelines using dynamic config - CircleCI
In this post, I will walk you through how to implement dynamic configuration by creating a config file that is not in the...
Read more >
salesforce/core ConfigAggregator resolving config file from ...
The problem is that no matter what I try, ConfigAggregator never returns local project configs. I have checked the github repo and found...
Read more >
TypeScript TS6053: File ' .ts' not found - Stack Overflow
I got this "TS6053" error because Visual Studio 2017 didn't find a folder I added to a Angularjs project. The solution posted above...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
systemPrefs with at least two files" status:RESOLVED resolution:OBSOLETE severity: ... Bug:126571 - "bug in kernel: amd64-agp fails to configure agp-bridge" ...
Read more >
Angular workspace configuration
The angular.json file at the root level of an Angular workspace provides ... of the configuration file does not correspond exactly to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found