模块分析失败:括号模式您可能需要适当的加载程序来处理此文件类型

Nik*_*hou 11 webpack angular

我使用以下命令创建了一个全新的angular 2应用程序:

ng init
ng server
Run Code Online (Sandbox Code Playgroud)

我收到此错误输出:

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') {
Run Code Online (Sandbox Code Playgroud)

谁能解释为什么我会收到这个错误?我看到报告了很多类似的错误,但不完全是这种变化.

更多细节

我可以说ng服务在同一台机器上的另一个angular-2应用程序文件夹中运行良好,我比较了这两个文件夹,但没有看到任何可以解释这种行为的明显差异.

我使用带有最新iOS的Mac,这是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
Run Code Online (Sandbox Code Playgroud)

Pie*_*her 14

导致此失败的依赖关系现在已更新.如果卸载webpack并重新安装webpack,它会将acorn更新到4.0.7版.这应该可以解决您的问题.

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

或者只是跑步

npm i acorn@4.0.8 来自项目目录(感谢@nodarii)