我正在按照https://angular.io/guide/aot-compiler的说明获取一个AOT版本。
根据Bootstrap部分,您需要将您的main.ts从以下位置切换:
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);要这样做:
import '../aot/App/app.module.ngfactory';
platformBrowserDynamic().bootstrapModule(AppModuleNgFactory);但是,在切换之后,当我运行ngc编译器时,我得到了这个错误:
Error: Command failed: C:\Windows\system32\cmd.exe /s /c "ngc -p tsconfig-aot.json"
TypeError: base64 is not a function
at Function.from (native)
at Function.from (native)
at Object.extractInlineSourceMap (E:\myapp\Sources\Web\node_modules\tsickle\build\src\source_map_utils.js:33:19)
at TsickleCompilerHost.stripAndStoreExistingSourceMap (E:\myapp\Sources\Web\node_modules\tsickle\build\src\tsickle_compiler_host.js:128:48)
at TsickleCompilerHost.getSourceFile (E:\myapp\Sources\Web\node_modules\tsickle\build\src\tsickle_compiler_host.js:89:25)
at findSourceFile (E:\myapp\Sources\Web\node_modules\typescript\lib\typescript.js:67909:29)
at processImportedModules (E:\myapp\Sources\Web\node_modules\typescript\lib\typescript.js:68056:25)
at findSourceFile (E:\myapp\Sources\Web\node_modules\typescript\lib\typescript.js:67937:17)
at processSourceFile (E:\myapp\Sources\Web\node_modules\typescript\lib\typescript.js:67840:27)
at processRootFile (E:\myapp\Sources\Web\node_modules\typescript\lib\typescript.js:67728:13)
Compilation failed
at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:821:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)我知道"Base64 is not a function error in Node.JS 5.3 and below" problem,但我使用的是NodeJS v8.2.1。
发布于 2017-08-31 20:58:53
尝试以下代码:
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from './aot/app/app.module.ngfactory';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);https://stackoverflow.com/questions/45981335
复制相似问题