angular - 尝试在没有节点的情况下运行 Angular 4

标签 angular systemjs

我是 .net/php/sql/JavaScript/Angular 1 开发人员,我现在对 Angular 2/4 感到有点迷茫。

我想在没有 Node.JS 的情况下运行 Angular 4

1) 我下载了在 https://angular.io/guide/setup 上找到的 QuickStart 种子 (直接链接:https://github.com/angular/quickstart/archive/master.zip)

2) 按照 How to run AngularJS2 application without Node server 中的建议 我从 https://github.com/systemjs/systemjs 下载了 SystemJS

3) 这是我当前的 html:

<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">
    <script src="systemjs/system.js"></script>
    <script>
      SystemJS.import('test.js')
    </script>
  </head>
  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>

在行之后,我得到

SyntaxError: import declarations may only appear at top level of a module

在 system.js 的第 1 行上显示

import { global, isBrowser, isWorker } from './common.js';

我怎样才能克服这个错误?

最佳答案

尝试使用 angular-cli 创建一个应用 https://github.com/angular/angular-cli

ng new myApp

然后,构建成静态html

ng build --prod

您的开发环境中只需要 node。使用 ng build 你的代码被捆绑并准备好用于任何共享主机

关于angular - 尝试在没有节点的情况下运行 Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44750306/

相关文章:

javascript - Karma/systemjs 尝试运行测试时不查找 node_modules 目录

javascript - : No provider for NgControl Angular AOT 中的错误

css - Angular scss 不适用于 ngx-datatable

javascript - 如何从捆绑文件中导入命名的 SystemJS 模块?

angular - 模块 'undefined' 导入的意外值 '...'

javascript - CSS 与 SystemJS/jspm

javascript - 在模板中包含包含 html 的变量 - angular2

Angular2从Odata Controller 获取数据

css - 动态多列下拉菜单 - Angular2 和 Bootstrap

angularjs - 为什么在 AngularJS 中使用 Typescript 时需要 “declare var angular”?