我是 .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/