Tag: 通用

SyntaxError:在使用第三方模块时,在Angular 2 Universal中意外的令牌导入

您好我得到一个SyntaxError当我运行server.ts ng生成Angular Universal后(npm开始看package.json)。 这只会发生,如果我运行server.ts,只有当我使用Angularitics2或AdsenseModule第三方模块。 ng服务工作得很好。 我认为这与ng的构build和编译有关。 我遵循这个教程,以使全球工作。: https : //coursetro.com/posts/code/68/Make-your-Angular-App-SEO-Friendly- 控制台中的错误: [root@mainframe core]$ ts-node src/server.ts /var/www/uni-app/core/node_modules/angulartics2/dist/core/angulartics2.js:1 (function (exports, require, module, __filename, __dirname) { import { Injectable } from '@angular/core'; ^^^^^^ SyntaxError: Unexpected token import at Object.exports.coreInThisContext (vm.js:78:16) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) […]

Webpack 2代码与服务器端渲染和React-Router-v4分离

使用webpack2.2.0-rc1并响应routerv4,并使用这个要点使代码分裂工作,这说明以下 function asyncComponent(getComponent) { return class AsyncComponent extends React.Component { static Component = null; state = { Component: AsyncComponent.Component }; componentWillMount() { if (!this.state.Component) { getComponent().then(Component => { AsyncComponent.Component = Component this.setState({ Component }) }) } } render() { const { Component } = this.state if (Component) { return <Component {…this.props} /> } return null […]