当前位置: 动力学知识库 > 问答 > 编程问答 >

angular2 - Module parse failed: Parenthesized pattern You may need an appropriate loader to handle this file type

问题描述:

I have created a brand new angular 2 application using these commands:

ng init

ng server

I get this error output:

chunk {1} styles.bundle.js, styles.bundle.map (styles) 9.96 kB {3} [initial] [rendered]

chunk {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.65 MB [initial] [rendered]

chunk {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in ./~/@angular/core/src/util/decorators.js

Module parse failed: /Users/nikolaschou/Dev/coziv/sandbox01/blockhowapp/temp/node_modules/@angular/core/src/util/decorators.js Parenthesized pattern (156:12)

You may need an appropriate loader to handle this file type.

|if (clsDef.hasOwnProperty('extends')) {

| if (typeof clsDef.extends === 'function') {

Can anyone explain why I might get this error? I see a lot of similar errors reported, but not exactly this variation.

More details

I can say that ng serve works well from another angular-2 application folder on the same machine and I have compared these two folders but don't see any obvious differences that can explain this behavior.

I use a Mac with latest iOS and this is the output from ng --version:

angular-cli: 1.0.0-beta.26

node: 6.6.0

os: darwin x64

@angular/common: 2.4.5

@angular/compiler: 2.4.5

@angular/core: 2.4.5

@angular/forms: 2.4.5

@angular/http: 2.4.5

@angular/platform-browser: 2.4.5

@angular/platform-browser-dynamic: 2.4.5

@angular/router: 3.4.5

@angular/compiler-cli: 2.4.5

网友答案:

The dependency that caused this to fail is now updated. If you uninstall webpack and reinstall webpack it will update acorn to version 4.0.7. This should solve your issue.

https://github.com/ternjs/acorn/issues/502

or just run

npm i [email protected] from the project directory (thanks @nodarii)

分享给朋友:
您可能感兴趣的文章:
随机阅读: