angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

Web cannot run after update angular cli to 6.1.0 #11661

Closed yeah007 closed 6 years ago

yeah007 commented 6 years ago

Web cannot run after update angular cli to 6.1.0

Command (mark with an x)

--update angular cli---
npm i -g npm
npm install -g typescript
npm install -g @angular/cli
npm install

---run application---
ng serve --open

Versions

node v8.11.2 npm v6.2.0 ng version

Angular CLI: 6.1.0 Node: 8.11.2 OS: win32 x64 Angular: ...

Package Version

@angular-devkit/architect 0.7.0 @angular-devkit/core 0.7.0 @angular-devkit/schematics 0.7.0 @schematics/angular 0.7.0 @schematics/update 0.7.0 rxjs 6.2.2 typescript 2.7.2

The log given by the failure

Cannot read property 'write' of undefined TypeError: Cannot read property 'write' of undefined at UI.write (viewer\node_modules\@angular\cli\ember-cli\lib\ui\index.js:56:23) at UI.writeLine (viewer\node_modules\@angular\cli\ember-cli\lib\ui\index.js:69:8) at Class.run (viewer\node_modules\@angular\cli\tasks\serve.js:237:12) at check_port_1.checkPort.then.port (viewer\node_modules\@angular\cli\commands\serve.js:123:26) at at process._tickCallback (internal/process/next_tick.js:188:7)

dejobo commented 6 years ago

so do we. same error!

MehranJanfeshan commented 6 years ago

@dejobo @yeah007 I have downgraded ng CLI to 6.0.8 and it works for me.

hansl commented 6 years ago

Hi @yeah007 ,

Are you sure you are running ng version inside your project? We do not have nor publish an ember-cli folder anymore, since 6.0.0, so I'm pretty sure this is a version mismatch and something is not right in your node_modules.

I'm going to close this issue as not a bug. If you cannot figure out the error, please file a new issue and share your package.json and a proper ng version run from the project directory (we want to know what the local version is).

azulay7 commented 6 years ago

@hansl same happend to me :( I've tryed ng version same error:

Cannot read property 'write' of undefined TypeError: Cannot read property 'write' of undefined at UI.write (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\ember-cli\lib\ui\index.js:56:23) at UI.writeLine (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\ember-cli\lib\ui\index.js:69:8) at Class.run (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\commands\version.js:71:17) at resolve (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\ember-cli\lib\models\command.js:261:20) at new Promise () at Class.validateAndRun (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\ember-cli\lib\models\command.js:240:12) at Promise.resolve.then.then (C:\dev\Goldmine\GoldMineWebApp\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:140:24) at at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:695:11)

lucaslacerdacl commented 6 years ago

Same error when run the command: ng build --prod --aot

Aenigma commented 6 years ago

I got this error and it seems to stem from the fact that I have an older version of ng cli on the project vs the version of ng cli installed globally.

I was able to fix this by updating the local ng cli version manually and then migrating it by running:

npm install --save-dev @angular/cli@6.1.1
yarn add -D @angular/cli@6.1.1 # if you use yarn

ng update @angular/cli --migrate-only --from=1.7.4

For CI builds, it may be worthwhile to invoke ./node_modules/.bin/ng instead of installing @angular/cli globally.

azulay7 commented 6 years ago

@Aenigma ng update @angular/cli --migrate-only --from=1.7.4 didn't work . actually ng -v gives the same error.

marcosrodriigues commented 6 years ago

same for me...include ng -v gives the error.

npm -v 6.2.0

node -v v10.7.0

the code

ng update @angular/cli --migrate-only --from=1.7.4 isn't work, I've got this error:

image

axacheng commented 6 years ago

It's certainly related to angular-cli latest release - 6.1.0 and 6.1.1 yesterday.

My workaround was downgraded angular-cli to 6.0.8.

$ ng serve
Your global Angular CLI version (6.1.0) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Cannot read property 'write' of undefined
TypeError: Cannot read property 'write' of undefined
    at UI.write (/Users/axa/workspace/sense/web/node_modules/@angular/cli/ember-cli/lib/ui/index.js:56:23)
    at UI.writeLine (/Users/axa/workspace/sense/web/node_modules/@angular/cli/ember-cli/lib/ui/index.js:69:8)
    at Class.run (/Users/axa/workspace/sense/web/node_modules/@angular/cli/tasks/serve.js:237:12)
    at check_port_1.checkPort.then.port (/Users/axa/workspace/sense/web/node_modules/@angular/cli/commands/serve.js:123:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

[[[ RESOLUTION HERE ]]]
$ sudo -s npm uninstall -g @angular/cli
$ sudo -s npm install -g @angular/cli@6.0.8
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.4 install /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

[fsevents] Success: "/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> @angular/cli@6.0.8 postinstall /usr/local/lib/node_modules/@angular/cli
> node ./bin/ng-update-message.js

+ @angular/cli@6.0.8
added 314 packages from 208 contributors in 4.595s

axa 🌤  gcloud@sense in ~/workspace/sense/web on master [?]
$ ng serve
Your global Angular CLI version (6.0.8) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-07-27T07:44:48.741Z
Hash: 3213f8632590f1521de1
Time: 22632ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 3.46 MB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.09 MB [initial] [rendered]
chunk {scripts} scripts.bundle.js (scripts) 1.09 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 2.48 MB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 24.9 MB [initial] [rendered]

webpack: Compiled successfully.

axa 🌤  gcloud@sense in ~/workspace/sense/web on master [?]
marcosrodriigues commented 6 years ago

@axacheng it works for me.

My problem was a little bit difference, I've got 'angular.json' error after execute these steps. To solution the problem, I've execute the followings commands at terminal:

1 - npm un @angular/cli@6.1.0 -g --save 2 - npm i @angular/cli@6.0.8 -g --save

After that, I've got something like this:

Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found.

So I've execute:

ng update @angular/cli --migrate-only --from=1.7.4

and ng serve works!

yeah007 commented 6 years ago

Yes, it works after revert to 6.0.8. It seems a issue of 6.1.0.

ahmed3eraqi commented 6 years ago

@axacheng thank you very much it's worked with me

csotomon commented 6 years ago

6.1.1 keep this error

Aenigma commented 6 years ago

@azulay7 I updated my previous comment. I failed to mention, because I didn't realize it was significant, that I first updated Angular CLI manually and then I ran ng update. This approach should let you safely upgrade to the latest version of Angular CLI.

npm install --save-dev @angular/cli@6.1.1
# now, ng version should work
ng update @angular/cli --migrate-only --from=1.7.4
azulay7 commented 6 years ago

thank @Aenigma @marcosrodriigues. works for me!

jpCamino commented 6 years ago

@marcosrodriigues thanks that worked

ugocoder commented 6 years ago

Issue has been fixed in v 6.1.4 npm update -g @angular/cli

angular-automatic-lock-bot[bot] commented 5 years ago

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.