使用ng build -–prod
他是我安装模块的方式
npm install ng-semantic --save
npm install jquery --save
我的angular-cli.json文件
"styles": [
"../semantic/dist/semantic.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../semantic/dist/semantic.js"
]
我的app.module.ts
import { NgSemanticModule } from "ng-semantic";
...
imports: [
NgSemanticModule
...
]
我的package.json
{
"name": "someproject",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/compiler-cli": "^2.4.10",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/platform-server": "^4.1.3",
"@angular/router": "^3.4.0",
"@types/jquery": "^2.0.45",
"chart.js": "2.5.0",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"ng-semantic": "^1.1.13",
"ng2-charts": "^1.5.0",
"rxjs": "^5.1.0",
"semantic-ui": "^2.2.10",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "1.0.0-beta.21",
"@angular/compiler-cli": "^2.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.0.0"
}
}
我尝试修复错误
在ng-semantic.d.ts
中添加了以下行import { NgModule } from '@angular/core';
...
@NgModule({
declarations: [
NgSemanticModule
]
})
export declare class NgSemanticModule {
}
在appmodule中尝试使用此行
import { NgSemanticModule } from "ng-semantic/ng-semantic";
也跟着这篇文章
答案 0 :(得分:1)
我在 ng-semantic.d.ts 文件中修复了此问题:
@NgModule()
export declare class NgSemanticModule {
}
相反:
@NgModule({
declarations: [
NgSemanticModule
]
})
export declare class NgSemanticModule {
}