将Angular2向导包添加到项目
我正在从一个角度开始一个项目。 我一直在创建自己的组件,现在我想添加npm包 我已经使用以下命令安装了这个包将Angular2向导包添加到项目,angular,npm,Angular,Npm,我正在从一个角度开始一个项目。 我一直在创建自己的组件,现在我想添加npm包 我已经使用以下命令安装了这个包 $ npm install angular2-wizard --save 正如它在安装部分所述,然后尝试按照所有建议的步骤使用该组件。我可以在我的项目的node\u modules文件夹下看到一个以插件命名的文件夹 当我使用npm startI运行项目时,我发现了404错误 错误:(SystemJS)XHR错误(404未找到)加载 该项目有一个工作的demo(),但似乎没有使用Syst
$ npm install angular2-wizard --save
正如它在安装部分所述,然后尝试按照所有建议的步骤使用该组件。我可以在我的项目的node\u modules
文件夹下看到一个以插件命名的文件夹
当我使用npm start
I运行项目时,我发现了404错误
错误:(SystemJS)XHR错误(404未找到)加载
该项目有一个工作的demo(),但似乎没有使用SystemJS。我也尝试过增加这一行的建议
'angular2-wizard': 'npm:angular2-wizard/dist/index.js'
在映射配置下,但现在当包加载其组件时,我得到404错误
从中加载“/src/wizard.component”时出错
堆栈跟踪:
(SystemJS)XHR错误(404未找到)加载
这是app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { FormWizardModule } from 'angular2-wizard';
import { PizzaService } from './services/pizza.service'
@NgModule({
imports: [
BrowserModule,
FormsModule,
FormWizardModule
],
declarations: [ AppComponent ],
providers: [ PizzaService ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
有没有关于如何将此包添加到我的项目的提示?404是因为它正在尝试访问
node\u模块/angular2向导/dist/src/wizard.component
不存在
这是因为angular2向导中编译的index.js正在尝试执行require('./src/wizard.component')
。我相信他们的发行版并不能保证这一点,但是SystemJS为您提供了以下内容:-
…在system.config.js中查找
//当没有文件名和/或没有
将以下内容添加到“packages”中的systemjs.config.js中:
'node_modules/angular2-wizard/dist/src/': {
defaultExtension: 'js'
}
现在,您的systemjs.config.js应该如下所示:
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-wizard': 'npm:angular2-wizard/dist/index.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
},
'node_modules/angular2-wizard/dist/src/': {
defaultExtension: 'js'
}
}
});
})(this);
404是因为它试图访问
node\u模块/angular2向导/dist/src/wizard.component
不存在
这是因为angular2向导中编译的index.js正在尝试执行require('./src/wizard.component')
。我相信他们的发行版并不能保证这一点,但是SystemJS为您提供了以下内容:-
…在system.config.js中查找
//当没有文件名和/或没有
将以下内容添加到“packages”中的systemjs.config.js中:
'node_modules/angular2-wizard/dist/src/': {
defaultExtension: 'js'
}
现在,您的systemjs.config.js应该如下所示:
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-wizard': 'npm:angular2-wizard/dist/index.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
},
'node_modules/angular2-wizard/dist/src/': {
defaultExtension: 'js'
}
}
});
})(this);
你可以发布你的src/app/app.module.ts
我已经用文件内容编辑了帖子扫描你发布的src/app/app.module.ts
我已经用文件内容编辑了帖子传统上我建议你使用angular cli而不是SystemJS来更快地开发。它按照你的建议工作。我从Angular开始,所以我会像你说的那样尝试Angular cli。谢谢!另外,为了更快的开发,我建议您使用angular cli而不是SystemJS。我从Angular开始,所以我会像你说的那样尝试Angular cli。谢谢!