无法构建此Angular项目

时间:2018-01-07 10:09:38

标签: node.js angular npm typescript-typings

我使用Angular select组件从Internet下载了一个Angular项目。

以下是原始示例:

https://material.angular.io/components/select/overview#resetting-the-select-value

他们在以下链接上有一个演示:

https://stackblitz.com/angular/qodvbqymxae

我将该演示下载到我的计算机上,但在执行时:

$ ng serve

我收到错误:

ERROR in Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\entry_resolver.js:131:11)
    at Promise.resolve.then.then (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:239:54)
    at process._tickCallback (internal/process/next_tick.js:109:7)

正如您在以下完整输出中看到的那样:

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-01-07T09:15:56.348Z
Hash: 93425b9cdaae6fb908b2
Time: 10331ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 2.93 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 636 bytes [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 154 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 854 kB [initial] [rendered]

ERROR in Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\entry_resolver.js:131:11)
    at Promise.resolve.then.then (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:239:54)
    at process._tickCallback (internal/process/next_tick.js:109:7)

webpack: Failed to compile.
webpack: Compiling...
Date: 2018-01-07T09:15:58.101Z
Hash: c2a123371dfcb5513a4e
Time: 884ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 2.93 kB [initial]
chunk {polyfills} polyfills.bundle.js (polyfills) 636 bytes [initial]
chunk {styles} styles.bundle.js (styles) 154 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 854 kB [initial]

ERROR in Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\entry_resolver.js:131:11)
    at Promise.resolve.then.then (D:\_System\Hatuey\Desktop\angular-material-select\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:239:54)
    at process._tickCallback (internal/process/next_tick.js:109:7)

webpack: Failed to compile.

README.md提供的stackblitz.com文件中(导出时),他们说:

This project was generated with Angular CLI version 1.2.1.

在我的本地计算机上,我得到以下内容:

$ ng version
...
Angular CLI: 1.5.4
Node: 6.11.2
OS: win32 x64
Angular: 5.1.3
...

如果您想自己尝试,可以这样做:

$ mkdir angular-material-select
$ cd angular-material-select
$ git clone git@github.com:napolev/angular-material-select.git .
$ npm install
$ ng serve

如何让这个演示项目有效?

1 个答案:

答案 0 :(得分:2)

  1. AppModulemain.ts提取到自己的文件app.module.ts
  2. DemoMaterialModule中的main.ts提取到自己的文件中
  3. DemoMaterialModule添加到AppModule' imports列表