nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

Nx compatibility to upcoming Angular CLI v6 #396

Closed exequiel09 closed 6 years ago

exequiel09 commented 6 years ago

Angular CLI v6.0.0-rc.0 has been released an hour ago so i went on trying to upgrade some Angular dependencies to test it out. And here are the results:

After the upgrade, postinstall command throws an error.

$ ./node_modules/.bin/nx postinstall
module.js:549
    throw err;                                                                                           >
    ^

Error: Cannot find module 'cosmiconfig'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@nrwl/schematics/src/utils/common.js:3:19)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

So even if the postinstall command has thrown in an error, out of curiosity i tried running the serve command

An old project has been detected, which needs to be updated to Angular CLI 6.

Please run the following commands to update this project.

  ng update @angular/cli --migrate-only --from=1.7.1                                                        >
  npm i
Error: An old project has been detected, which needs to be updated to Angular CLI 6.

Please run the following commands to update this project.
                                                                                                                                  "
  ng update @angular/cli --migrate-only --from=1.7.1
  npm i
    at WorkspaceLoader._assertUpdatedWorkspace (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/workspace-loader.js:73:19)
    at WorkspaceLoader._getProjectWorkspaceFilePath (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/workspace-loader.js:29:14)
    at WorkspaceLoader.loadWorkspace (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/workspace-loader.js:25:21)
    at ServeCommand._loadWorkspaceAndArchitect (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/architect-command.js:151:32)
    at ServeCommand.<anonymous> (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/architect-command.js:45:25)
    at Generator.next (<anonymous>)
    at /Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/architect-command.js:3:12)
    at ServeCommand.initialize (/Users/exequiel/Projects/repositories/test-nx-1/node_modules/@angular/cli/models/architect-command.js:44:16)

Versions

Angular CLI: 6.0.0-rc.0
Nrwl/Schematics: 0.9.1
Nrwl/Nx: 0.9.1
exequiel09 commented 6 years ago

The ng serve error might be related to: https://github.com/angular/angular-cli/issues/10163

mrmeku commented 6 years ago

I've looked into this a bit. The first thing to fix in nx is our package.json. These dependencies get us half way there:

{
  "name": "blah",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "./node_modules/.bin/nx lint && ng lint",
    "e2e": "ng e2e",
    "affected:apps": "./node_modules/.bin/nx affected apps",
    "affected:build": "./node_modules/.bin/nx affected build",
    "affected:e2e": "./node_modules/.bin/nx affected e2e",
    "format": "./node_modules/.bin/nx format write",
    "format:write": "./node_modules/.bin/nx format write",
    "format:check": "./node_modules/.bin/nx format check",
    "update": "./node_modules/.bin/nx update",
    "update:check": "./node_modules/.bin/nx update check",
    "update:skip": "./node_modules/.bin/nx update skip",
    "postinstall": "./node_modules/.bin/nx postinstall"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.0.0-rc.1",
    "@angular/common": "6.0.0-rc.1",
    "@angular/compiler": "6.0.0-rc.1",
    "@angular/core": "6.0.0-rc.1",
    "@angular/forms": "6.0.0-rc.1",
    "@angular/platform-browser": "6.0.0-rc.1",
    "@angular/platform-browser-dynamic": "6.0.0-rc.1",
    "@angular/router": "6.0.0-rc.1",
    "core-js": "^2.4.1",
    "rxjs": "6.0.0-beta.4",
    "zone.js": "^0.8.19",
    "@nrwl/nx": "0.10.0-beta.1",
    "@ngrx/effects": "6.0.0-beta.1",
    "@ngrx/router-store": "5.0.1",
    "@ngrx/store": "6.0.0-beta.1",
    "@ngrx/store-devtools": "6.0.0-beta.1",
    "ngrx-store-freeze": "^0.2.1"
  },
  "devDependencies": {
    "@angular/cli": "6.0.0-rc.0",
    "@angular/compiler-cli": "6.0.0-rc.1",
    "@nrwl/schematics": "0.10.0-beta.1",
    "@angular/language-service": "6.0.0-rc.1",
    "@schematics/angular": "^0.5.0",
    "@schematics/update": "^0.5.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "cosmiconfig": "^4.0.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "2.7.2",
    "prettier": "1.10.2"
  }
}

The second half of the migration will involve migrating to RxJS 6.0. Currently, with the set of dependencies we have the following error is produced by ng serve

ERROR in node_modules/@nrwl/nx/src/data-persistence.d.ts(5,10): error TS2305: Module '"/Users/mrmeku/temp/blah/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
mrmeku commented 6 years ago

But as for the original error that was produced about cosmiconfig not being found, that's an error with the angular cli. It should have listed the package as a peer dependency

mrmeku commented 6 years ago

The second error about not being able to run the cli migration can be resolved by adding two dependencies (which again should be been peer dependencies of the cli)

"@schematics/angular": "^0.5.0",
"@schematics/update": "^0.5.0",
nweldev commented 6 years ago

A comment about compatibility with Angular 6 :

exequiel09 commented 6 years ago

Closing since Nx now supports Angular CLI v6.

github-actions[bot] commented 1 year ago

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.