来自 CDN 的 angular2 加载我的页面,但我的代码 node_modules 中的 angular2 没有

angular2 from a CDN loads my page, but angular2 in my code's node_modules does not

当我在 index.html 中使用以下 CDN 来提供 angular2 时,我的页面加载了。

<script src="https://code.angularjs.org/2.0.0-alpha.47/angular2.dev.js"></script>

我在 node_modules 目录中的代码中有相同的 alpha.47 版本。该目录位于包含 index.html 的 angular2-oPost 目录的正下方。当我用

替换 CDN 脚本时
<script src="./angular2-oPost/node_modules/angular2/angular2.js"></script>

页面不再加载。

控制台错误以引用 angular2 代码的错误开头:

ReferenceError: require is not defined    angular2.js: 4:1
http://localhost/angular2-oPost/angular2/angular2.js    404 not found

然后http://localhost/angular2-oPost/angular2/开头的找不到很多。 . .

引用错误在Google的代码中。 404 表示某些东西正在不存在的目录中寻找 angular2。 angular2.js 正在寻找其他东西吗?我应该改变什么?

就像 Eric 说的你指向了错误的文件,你需要指向:

node_modules/angular2/bundles/angular2.js

node_modules/angular2/bundles/angular2.dev.js

它们的用途从名称本身就很明显,angular2。dev.js它的意思是用于开发环境,另一个用于生产。

虽然我不知道它们之间的所有确切区别,但我相信主要想法是在错误记录中做更少的细节,但我自己还没有注意到它,并不是我太注意了。

同时检查:
- https://github.com/angular/angular/issues/3458
-

看起来像提议 "should" 是什么,但是 "beta" 中看起来像 epsilon 的东西可能不是真的,或者至少现在还不是。