我是.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
下载了SystemJS3)这是我目前的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声明只能出现在模块的顶层
在system.js的第1行读取
import { global, isBrowser, isWorker } from './common.js';
如何解决该错误?
答案 0 :(得分:3)
尝试使用angular-cli https://github.com/angular/angular-cli
创建应用ng new myApp
然后,构建到静态html
ng build --prod
您只需要开发环境中的节点。使用ng build,您的代码将被捆绑并准备好用于任何共享主机