angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Latest Webpack version of CLI throws error

Open siva636 opened this issue 10 years ago • 22 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Ubuntu latest 16.04 LTS
  2. Versions. Please run ng --version. If there's nothing outputted, please run When run ng --version the following error comes: siva@siva:~$ ng --version Error while running script "/home/siva/Applications/node-v4.4.3-linux-x86/lib/node_modules/angular-cli/addon/ng2/models/config/config.ts": SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.require.extensions..ts (/home/siva/Applications/node-v4.4.3-linux-x86/lib/node_modules/angular-cli/lib/bootstrap-local.js:30:14) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/siva/Applications/node-v4.4.3-linux-x86/lib/node_modules/angular-cli/addon/ng2/models/config.ts:7:16) at Module._compile (module.js:409:26) at Object.require.extensions..ts (/home/siva/Applications/node-v4.4.3-linux-x86/lib/node_modules/angular-cli/lib/bootstrap-local.js:30:14)

in a Terminal: node --version and paste the result here:

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
  2. The log given by the failure. Normally this include a stack trace and some more information.
  3. Mention any other details that might be useful.

Thanks! We'll be in touch soon.

siva636 avatar Aug 30 '16 06:08 siva636

try install npm install -g [email protected]

Daredzik avatar Aug 30 '16 06:08 Daredzik

have the same issue, but according to this thread #1883 you now need node6 and not node4

olsn avatar Aug 30 '16 08:08 olsn

Updating node from 6.3.0 to 6.5.0 helped me too for this problem.

TunaYagci avatar Aug 30 '16 08:08 TunaYagci

to fix this u need go ng init, coz angular-cli.json was modify !! need to write about it on changelog !!.

go ng init, and go yes only for angular-cli.json and polyfills.ts

Daredzik avatar Aug 30 '16 09:08 Daredzik

I' trying the new angular-cli: 1.0.0-beta.11-webpack.8 ...

System: Mac OSX El Capitan

$ ng --version Could not start watchman; falling back to NodeWatcher for file system events. Visit http://ember-cli.com/user-guide/#watchman for more info. angular-cli: 1.0.0-beta.11-webpack.8 node: 6.5.0 os: darwin x64

Repro steps. ng new projname cd projname ng serve

Errors Project is running but the console reports tons of typings errors like the followings

ERROR in [default] /Users/user/webProjects/test-angular2/webpack/node_modules/@angular/core/src/di/reflective_key.d.ts:18:11 Cannot find name 'Object'.

ERROR in [default] /Users/user/webProjects/test-angular2/webpack/node_modules/@angular/core/src/di/reflective_key.d.ts:23:23 Cannot find name 'Object'.

ERROR in [default] /Users/user/webProjects/test- angular2/webpack/node_modules/@angular/core/src/di/reflective_key.d.ts:31:22 Cannot find name 'Object'.

ERROR in [default] /Users/user/webProjects/test-angular2/webpack/node_modules/@angular/core/src/di/reflective_provider.d.ts:71:13 Cannot find name 'Function'.

ERROR in [default] /Users/user/webProjects/test-angular2/webpack/node_modules/@angular/core/src/di/reflective_provider.d.ts:80:17 Cannot find name 'Function'.

kurtommy avatar Aug 30 '16 21:08 kurtommy

This morning things were fine. Now when I create a project and run ng build or ng serve I observe all these errors.

Running on a MacbookPro / El Capitan: ng --version Could not start watchman; falling back to NodeWatcher for file system events. Visit http://ember-cli.com/user-guide/#watchman for more info. angular-cli: 1.0.0-beta.11-webpack.8 node: 6.2.1 os: darwin x64

Additional Note: The app runs, regardless. Kind of hard to debug though!

ghost avatar Aug 30 '16 21:08 ghost

Why in CHANGELOG.md the newest version is 1.0.0-beta.11-webpack.3 but everyone is installing 1.0.0-beta.11-webpack.8?

Kosmonaft avatar Aug 31 '16 00:08 Kosmonaft

[email protected] is what is installed with one installs angular-cli@webpack, which is recommended in the angular-cli installation page for RC5 / webpack.

ghost avatar Aug 31 '16 01:08 ghost

it is a moving target! Hopefully this is a better version. I'll check it out right now and let you know what I observe.

ghost avatar Aug 31 '16 01:08 ghost

I had really strange situation. I run npm install -g angular-cli@webpack Than I checked the version ng -v and it was angular-cli 1.0.0-beta.10 I decided to remove it npm uninstall angular-cli, than npm cache clean. To ensure that it's deleted I run one more time ng -v and for my surprise the version was 1.0.0-beta.11-webpack.8

I don't have any idea what just happened

Kosmonaft avatar Aug 31 '16 01:08 Kosmonaft

I love it! I just finished the same exercise and got 1.0.0-beta.11-webpack.8! I guess you had an optical illusion (happens to me lot, particularly while playing chess!). Tje problem with the typings still remains.

ghost avatar Aug 31 '16 02:08 ghost

OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

MacbookPRO / El Capitan

$ node --version
v6.5.0

$ npm --version
3.10.3

$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

Repro steps. Was this an app that wasn't created using the CLI? What change did you

do on your code? etc. Using the above configuration I executed the following steps

$ ng build my_project
$ cd my_project
$ ng build

The log given by the failure. Normally this include a stack trace and some

more information.

This issue seems to be related to issue #1873

It has been suggested that upgrading to node 6.5.0 might solve the problem. Unfortunately, as shown by the logs below, this is not the case:

$ node --version
v6.5.0

$ npm --version
3.10.3

$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

$ ng build
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
1019ms building modules                                                              
1ms sealing 
0ms optimizing 
1ms basic module optimization 
1ms module optimization 
0ms advanced module optimization 
2ms basic chunk optimization        
1ms chunk optimization 
0ms advanced chunk optimization 
0ms module and chunk tree optimization 
3ms module reviving 
0ms module order optimization 
0ms module id optimization 
1ms chunk reviving 
0ms chunk order optimization 
1ms chunk id optimization 
2ms hashing 
0ms module assets processing 
6ms chunk assets processing 
1ms additional chunk assets processing 
0ms recording 
1ms additional asset processing 
76ms chunk asset optimization
193ms asset optimization
4ms emitting 
Hash: 8633515b4611dd25238a
Version: webpack 2.1.0-beta.21
Time: 1329ms
            Asset       Size  Chunks             Chunk Names
   main.bundle.js    19.3 kB    0, 2  [emitted]  main
 styles.bundle.js      13 kB    1, 2  [emitted]  styles
        inline.js    5.53 kB       2  [emitted]  inline
         main.map    15.4 kB    0, 2  [emitted]  main
       styles.map    17.9 kB    1, 2  [emitted]  styles
       inline.map    5.59 kB       2  [emitted]  inline
       index.html  481 bytes          [emitted]  
assets/.npmignore    0 bytes          [emitted]  
chunk    {0} main.bundle.js, main.map (main) 13.8 kB {1} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.map (styles) 12.7 kB {2} [initial] [rendered]
chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve '@angular/platform-browser-dynamic' in '/Users/silveir/Projects/studies/ng2_router/src'
 @ ./src/main.ts 2:0-75
 @ multi main

.... many more errors of this nature

Mention any other details that might be useful.

Ive tried the steps above with many different typescript versions

ghost avatar Aug 31 '16 14:08 ghost

I was able to solve this problem with the following configuration:

Upgrade imy tools

 node --version
v6.5.0
$ npm --version
3.10.3
$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

$ npm list -g
/usr/local/lib
├─┬ [email protected]
│ ├── @angular-cli/[email protected]

...

├── [email protected]

....

Changed "typescript": "^2.0.0"to "typescript": "2.0.0"in mypackages.json`

Executed the folling commands on my project root

$ rm -rf node_modules dist tmp typings
$ npm install --save-dev angular-cli@webpack

ghost avatar Aug 31 '16 16:08 ghost

Thanks @dematic-rodrigo-silveira Changing "typescript": "^2.0.0"to "typescript": "2.0.0"in packages.json works

Now i've upgraded the structure of my project comparing folders and files from a fresh ng new project, there are several differences. Now i've got this errors and i can't figure out where to remove undefined from the path see the errors below

ERROR in multi main
Module not found: Error: Can't resolve '/Users/user/webProjects/musicollector/undefined/main.ts' in '/Users/user/webProjects/musicollector/node_modules/angular-cli/addon/ng2/models'
 @ multi main

ERROR in Entry module not found: Error: Can't resolve '/Users/user/webProjects/musicollector/undefined/polyfills.ts' in '/Users/user/webProjects/musicollector/node_modules/angular-cli/addon/ng2/models'

ERROR in   Error: Child compilation failed:
  Entry module not found: Error: Can't resolve '/Users/user/webProjects/musicolle  ctor/undefined/index.html' in '/Users/user/webProjects/musicollector/node_modul  es/angular-cli/addon/ng2/models':
  Error: Can't resolve '/Users/user/webProjects/musicollector/undefined/index.htm  l' in '/Users/user/webProjects/musicollector/node_modules/angular-cli/addon/ng2  /models'

kurtommy avatar Aug 31 '16 17:08 kurtommy

Thanks @dematic-rodrigo-silveira also, as @kurtommy said, no more typings errors appear. But, I still have issues with MS Visual Code and intellisense.

With:

$ nvm use v4
$ ng --version
angular-cli: 1.0.0-beta.10
node: 4.5.0
os: darwin x64
$ npm --version
3.10.7
$ npm cache clean
$ ng new test-10
$ code test-10

it works perfectly, as expected.

With:

$ nvm use v6
$ ng --version
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64
$ npm --version
3.10.7
$ tsc --version
Version 2.0.0
$ npm cache clean
$ ng new test-11
$ code test-11

MS Studio Code reports some problems (although it is compiled ok):

[ts] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. [ts] Cannot find name 'Promise'.

¿Any idea?

drpicox avatar Sep 01 '16 15:09 drpicox

As it was mentioned before you should do next steps to fix this bug:

  1. Install typescript 2.0.0 npm uninstall typescript -g npm cache clean npm install [email protected] -g
  2. ng init in project folder
  3. Change the line "typescript": "^2.0.0" to "typescript": "2.0.0" in package.json
  4. run npm install
  5. Enjoy your project.

For me it works good. Versions: angular-cli: 1.0.0-beta.11-webpack.8 node: 6.5.0 os: darwin x64

DMezhenskyi avatar Sep 02 '16 18:09 DMezhenskyi

Nop. ng serve does not throw any error, but MS Visual Code still reporting the same errors.

drpicox avatar Sep 02 '16 22:09 drpicox

When the next version of CLI likely to come out?

siva636 avatar Sep 07 '16 09:09 siva636

Closing as obsolete.

@siva636 please try the latest beta.14.

The typescript@^2.0.0 - >2.0.0 issue was fixed in https://github.com/angular/angular-cli/pull/1993.

Errors in your editors are because they might not support typescript 2.0.0 yet, there might be a way to configure the editor but it varies.

For other problems please open separate issues.

filipesilva avatar Sep 16 '16 01:09 filipesilva

Now (beta.14) it is working ok (like beta.10) with MS Visual Code. (may be is the editor that has been updated to v1.5.2) Thanks @filipesilva

drpicox avatar Sep 16 '16 06:09 drpicox