Angular2 intelliJ 配置错误.. 找不到模块'@angular/core'
Angular2 intelliJ config error.. Cannot find module '@angular/core'
我是 Angular2 的新手。我正在关注 Tutorial Angular2 by Example
。这是第一个简单的教程,叫做猜数字
我使用的代码完全按照 github 提供的示例中的描述
https://github.com/chandermani/angular2byexample/tree/master/guessthenumber.
它在浏览器中加载正常。这是我遇到问题的 IntelliJ 设置。
IntelliJ 返回以下错误...如屏幕截图所示。
找不到模块“@angular/core”
我的属性文件如下
systemjs.config.js
System.config({
map : {
'app': 'app',
'rxjs': 'https://unpkg.com/rxjs@5.0.0-beta.12',
'@angular/common': 'https://unpkg.com/@angular/common@2.0.0',
'@angular/compiler': 'https://unpkg.com/@angular/compiler@2.0.0',
'@angular/core': 'https://unpkg.com/@angular/core@2.0.0',
'@angular/platform-browser': 'https://unpkg.com/@angular/platform-browser@2.0.0',
'@angular/platform-browser-dynamic': 'https://unpkg.com/@angular/platform-browser-dynamic@2.0.0'
},
packages:{
'app': { main: 'main.ts', defaultExtension: 'ts' },
'@angular/common': { main: 'bundles/common.umd.js', defaultExtension: 'js' },
'@angular/compiler': { main: 'bundles/compiler.umd.js', defaultExtension: 'js' },
'@angular/core': { main: 'bundles/core.umd.js', defaultExtension: 'js' },
'@angular/platform-browser': { main: 'bundles/platform-browser.umd.js', defaultExtension: 'js' },
'@angular/platform-browser-dynamic': { main: 'bundles/platform-browser-dynamic.umd.js', defaultExtension: 'js' },
},
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
}
});
My thoughts on a potential solution?
当前从 https://unpkg.com/@angular/core@2.0.0 加载模块,但 IntelliJ 更希望从计算机上的文件加载它?我应该在本地托管文件吗?
Intellij 不知道 systemjs.config.js 文件?我需要创建一个 tsconfig.json 文件吗?那个Intellij能看懂?
是的,我认为您需要创建 tsconfig.json、
并在 IntelliJ 设置中打开 typescript 编译器
这个也可以帮到你
错误来自 TS 编译器。是的,就像 Idea 本身一样,它无法通过系统配置中的 CDN 引用找到 @angular
模块:它需要模块在您的项目中本地可用(例如通过 npm 安装 - 请参阅 https://angular.io/docs/ts/latest/guide/setup.html ).像你这样的配置只有在使用基于浏览器的编译时才有效
我是 Angular2 的新手。我正在关注 Tutorial Angular2 by Example
。这是第一个简单的教程,叫做猜数字
我使用的代码完全按照 github 提供的示例中的描述 https://github.com/chandermani/angular2byexample/tree/master/guessthenumber.
它在浏览器中加载正常。这是我遇到问题的 IntelliJ 设置。
IntelliJ 返回以下错误...如屏幕截图所示。 找不到模块“@angular/core”
我的属性文件如下
systemjs.config.js
System.config({
map : {
'app': 'app',
'rxjs': 'https://unpkg.com/rxjs@5.0.0-beta.12',
'@angular/common': 'https://unpkg.com/@angular/common@2.0.0',
'@angular/compiler': 'https://unpkg.com/@angular/compiler@2.0.0',
'@angular/core': 'https://unpkg.com/@angular/core@2.0.0',
'@angular/platform-browser': 'https://unpkg.com/@angular/platform-browser@2.0.0',
'@angular/platform-browser-dynamic': 'https://unpkg.com/@angular/platform-browser-dynamic@2.0.0'
},
packages:{
'app': { main: 'main.ts', defaultExtension: 'ts' },
'@angular/common': { main: 'bundles/common.umd.js', defaultExtension: 'js' },
'@angular/compiler': { main: 'bundles/compiler.umd.js', defaultExtension: 'js' },
'@angular/core': { main: 'bundles/core.umd.js', defaultExtension: 'js' },
'@angular/platform-browser': { main: 'bundles/platform-browser.umd.js', defaultExtension: 'js' },
'@angular/platform-browser-dynamic': { main: 'bundles/platform-browser-dynamic.umd.js', defaultExtension: 'js' },
},
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
}
});
My thoughts on a potential solution?
当前从 https://unpkg.com/@angular/core@2.0.0 加载模块,但 IntelliJ 更希望从计算机上的文件加载它?我应该在本地托管文件吗?
Intellij 不知道 systemjs.config.js 文件?我需要创建一个 tsconfig.json 文件吗?那个Intellij能看懂?
是的,我认为您需要创建 tsconfig.json、
并在 IntelliJ 设置中打开 typescript 编译器
这个
错误来自 TS 编译器。是的,就像 Idea 本身一样,它无法通过系统配置中的 CDN 引用找到 @angular
模块:它需要模块在您的项目中本地可用(例如通过 npm 安装 - 请参阅 https://angular.io/docs/ts/latest/guide/setup.html ).像你这样的配置只有在使用基于浏览器的编译时才有效