我在项目中使用了jhipster。 在本项目中,我们将ui角设为5。 对于我的报告,请使用stimulsoft,我需要添加 report.js 和viewer.js到我的项目,但将其添加到vendor.ts之后,显示以下错误:
ERROR in ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
Module not found: Error: Can't resolve './ods' in
'D:\khosroshahi\project\boursamnew2\src\main\webapp\content\plugins\stimulsoft'
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js 129:100617-100636
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/sender.js
Module not found: Error: Can't resolve 'dgram' in 'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/sender.js 13:12-28
@ ./node_modules/tedious/lib/instance-lookup.js
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/pg/lib/connection-parameters.js
Module not found: Error: Can't resolve 'dns' in 'D:\khosroshahi\project\boursamnew2\node_modules\pg\lib'
@ ./node_modules/pg/lib/connection-parameters.js 2:10-24
@ ./node_modules/pg/lib/native/index.js
@ ./node_modules/pg/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/sender.js
Module not found: Error: Can't resolve 'dns' in 'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/sender.js 14:10-24
@ ./node_modules/tedious/lib/instance-lookup.js
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/connector.js
Module not found: Error: Can't resolve 'dns' in 'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/connector.js 18:10-24
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/mysql/lib/protocol/sequences/Query.js
Module not found: Error: Can't resolve 'fs' in 'D:\khosroshahi\project\boursamnew2\node_modules\mysql\lib\protocol\sequences'
@ ./node_modules/mysql/lib/protocol/sequences/Query.js 6:19-32
@ ./node_modules/mysql/lib/Connection.js
@ ./node_modules/mysql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/node-firebird/lib/messages.js
Module not found: Error: Can't resolve 'fs' in 'D:\khosroshahi\project\boursamnew2\node_modules\node-firebird\lib'
@ ./node_modules/node-firebird/lib/messages.js 1:9-22
@ ./node_modules/node-firebird/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/pgpass/lib/index.js
Module not found: Error: Can't resolve 'fs' in 'D:\khosroshahi\project\boursamnew2\node_modules\pgpass\lib'
@ ./node_modules/pgpass/lib/index.js 4:9-22
@ ./node_modules/pg/lib/client.js
@ ./node_modules/pg/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
Module not found: Error: Can't resolve 'fs' in 'D:\khosroshahi\project\boursamnew2\src\main\webapp\content\plugins\stimulsoft'
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js 129:137288-137301 133:64066-64079 133:64725-64738 133:65408-65421 133:65942-65955
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/mysql/lib/Connection.js
Module not found: Error: Can't resolve 'net' in 'D:\khosroshahi\project\boursamnew2\node_modules\mysql\lib'
@ ./node_modules/mysql/lib/Connection.js 3:23-37
@ ./node_modules/mysql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/node-firebird/lib/index.js
Module not found: Error: Can't resolve 'net' in 'D:\khosroshahi\project\boursamnew2\node_modules\node-firebird\lib'
@ ./node_modules/node-firebird/lib/index.js 2:10-24
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/pg/lib/connection.js
Module not found: Error: Can't resolve 'net' in 'D:\khosroshahi\project\boursamnew2\node_modules\pg\lib'
@ ./node_modules/pg/lib/connection.js 1:10-24
@ ./node_modules/pg/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/connector.js
Module not found: Error: Can't resolve 'net' in 'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/connector.js 17:10-24
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/sender.js
Module not found: Error: Can't resolve 'net' in
'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/sender.js 15:10-24
@ ./node_modules/tedious/lib/instance-lookup.js
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/pg/lib/native/index.js
Module not found: Error: Can't resolve 'pg-native' in 'D:\khosroshahi\project\boursamnew2\node_modules\pg\lib\native'
@ ./node_modules/pg/lib/native/index.js 1:13-33
@ ./node_modules/pg/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/mysql/lib/Connection.js
Module not found: Error: Can't resolve 'tls' in 'D:\khosroshahi\project\boursamnew2\node_modules\mysql\lib'
@ ./node_modules/mysql/lib/Connection.js 4:23-37
@ ./node_modules/mysql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/pg/lib/connection.js
Module not found: Error: Can't resolve 'tls' in 'D:\khosroshahi\project\boursamnew2\node_modules\pg\lib'
@ ./node_modules/pg/lib/connection.js 78:14-28
@ ./node_modules/pg/lib/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
ERROR in ./node_modules/tedious/lib/message-io.js
Module not found: Error: Can't resolve 'tls' in 'D:\khosroshahi\project\boursamnew2\node_modules\tedious\lib'
@ ./node_modules/tedious/lib/message-io.js 27:10-24
@ ./node_modules/tedious/lib/connection.js
@ ./node_modules/tedious/lib/tedious.js
@ ./node_modules/mssql/lib/tedious.js
@ ./node_modules/mssql/index.js
@ ./src/main/webapp/content/plugins/stimulsoft/stimulsoft.reports.js
@ ./src/main/webapp/app/vendor.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
@ multi (webpack)-dev-server/client?http://localhost:9060 webpack/hot/dev-server ./src/main/webapp/app/app.main
我使用yarn和My pakage.json是:
{
"name": "gwadmin",
"version": "0.0.0",
"description": "Description for gwadmin",
"private": true,
"license": "UNLICENSED",
"cacheDirectories": [
"node_modules"
],
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/cdk": "5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.7",
"@types/lodash": "4.14.117",
"angular-tree-component": "^7.0.1",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"font-awesome": "4.7.0",
"jalali-moment": "3.1.1",
"jquery": "3.2.1",
"material-icon-font": "^3.0.1",
"ng-jhipster": "0.3.4",
"ngx-cookie": "2.0.1",
"ngx-image-cropper": "0.1.14",
"ngx-infinite-scroll": "0.5.1",
"ngx-loading": "^1.0.14",
"ngx-progressbar": "^2.1.1",
"ngx-toastr": "^8.0.0",
"ngx-webstorage": "2.0.1",
"reflect-metadata": "0.1.10",
"rxjs": "^5.5.6",
"sockjs-client": "1.1.4",
"stimulsoft-reports-js": "2018.3.2",
"swagger-ui": "2.2.10",
"tether": "1.4.0",
"underscore": "1.8.3",
"webstomp-client": "1.0.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.4",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@ngtools/webpack": "1.8.5",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"angular2-template-loader": "0.6.2",
"awesome-typescript-loader": "3.2.2",
"browser-sync": "2.18.13",
"browser-sync-webpack-plugin": "1.2.0",
"codelyzer": "^4.0.1",
"copy-webpack-plugin": "4.2.3",
"css-loader": "0.28.4",
"exports-loader": "0.6.4",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"generator-jhipster": "4.13.0",
"html-loader": "0.5.0",
"html-webpack-plugin": "2.30.1",
"jasmine-core": "~2.8.0",
"jasmine-reporters": "2.2.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage": "1.1.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-intl-shim": "1.0.3",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "1.2.0",
"karma-notify-reporter": "1.0.1",
"karma-phantomjs-launcher": "1.0.4",
"karma-remap-istanbul": "0.6.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.4",
"merge-jsons-webpack-plugin": "1.0.11",
"node-sass": "4.5.3",
"phantomjs-prebuilt": "2.1.16",
"postcss-loader": "2.0.9",
"protractor": "~5.1.2",
"protractor-jasmine2-screenshot-reporter": "0.4.0",
"proxy-middleware": "0.15.0",
"rimraf": "2.6.1",
"sass-loader": "6.0.6",
"script-loader": "^0.7.2",
"sourcemap-istanbul-instrumenter-loader": "0.2.0",
"string-replace-webpack-plugin": "0.1.3",
"style-loader": "0.18.2",
"to-string-loader": "1.1.5",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"tslint-loader": "3.5.3",
"typescript": "~2.5.3",
"uglifyjs-webpack-plugin": "1.1.2",
"web-app-manifest-loader": "0.1.1",
"webpack": "^3.12.0",
"webpack-dev-server": "2.9.5",
"webpack-merge": "4.1.1",
"webpack-notifier": "1.5.0",
"webpack-visualizer-plugin": "0.1.11",
"workbox-webpack-plugin": "2.1.2",
"write-file-webpack-plugin": "4.1.0",
"xml2js": "0.4.17"
},
"engines": {
"node": ">=6.9.0"
},
"scripts": {
"lint": "tslint --project './tsconfig.json' -e 'node_modules/**'",
"lint:fix": "yarn run lint -- --fix",
"ngc": "ngc -p tsconfig-aot.json",
"cleanup": "rimraf target/{aot,www}",
"clean-www": "rimraf target//www/app/{src,target/}",
"start": "yarn run webpack:dev",
"serve": "yarn run start",
"build": "yarn run webpack:prod",
"test": "yarn run lint && karma start src/test/javascript/karma.conf.js",
"test:watch": "yarn test -- --watch",
"webpack:dev": "yarn run webpack-dev-server -- --config webpack/webpack.dev.js --progress --inline --hot --profile --port=9060 --watch-content-base",
"webpack:build:main": "yarn run webpack -- --config webpack/webpack.dev.js --progress --profile",
"webpack:build": "yarn run cleanup && yarn run webpack:build:main",
"webpack:prod:main": "yarn run webpack -- --config webpack/webpack.prod.js --progress --profile",
"webpack:prod": "yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www",
"webpack:test": "yarn run test",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
"e2e": "protractor src/test/javascript/protractor.conf.js",
"postinstall": "webdriver-manager update && node node_modules/phantomjs-prebuilt/install.js"
}
}
我使用webpack,而我的webpack.dev.js是:
const webpack = require('webpack');
const writeFilePlugin = require('write-file-webpack-plugin');
const webpackMerge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const path = require('path');
const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');
const ENV = 'development';
module.exports = webpackMerge(commonConfig({ env: ENV }), {
devtool: 'eval-source-map',
devServer: {
contentBase: './target/www',
proxy: [{
context: [
'/uaa',
/* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
'/api',
'/management',
'/swagger-resources',
'/v2/api-docs',
'/h2-console',
'/auth'
],
target: 'http://127.0.0.1:8056',
secure: false
},{
context: [
'/websocket'
],
target: 'ws://127.0.0.1:8056',
ws: true
}],
watchOptions: {
ignored: /node_modules/
}
},
entry: {
polyfills: './src/main/webapp/app/polyfills',
global: './src/main/webapp/content/scss/global.scss',
main: './src/main/webapp/app/app.main'
},
output: {
path: utils.root('target/www'),
filename: 'app/[name].bundle.js',
chunkFilename: 'app/[id].chunk.js'
},
module: {
rules: [{
test: /\.ts$/,
enforce: 'pre',
loaders: 'tslint-loader',
exclude: ['node_modules', new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
},
{
test: /\.ts$/,
loaders: [
'angular2-template-loader',
'awesome-typescript-loader'
],
exclude: ['node_modules/generator-jhipster']
},
{
test: /\.scss$/,
loaders: ['to-string-loader', 'css-loader', 'sass-loader'],
exclude: /(vendor\.scss|global\.scss)/
},
{
test: /\.exec\.js$/,
use: [ 'script-loader' ]
}
,
{
test: /(vendor\.scss|global\.scss)/,
loaders: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
},
{
test: /\.css$/,
loaders: ['to-string-loader', 'css-loader'],
exclude: /(vendor\.css|global\.css)/
},
{
test: /(vendor\.css|global\.css)/,
loaders: ['style-loader', 'css-loader']
}]
},
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 9000,
proxy: {
target: 'http://localhost:9060',
ws: true
}
}, {
reload: false
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new writeFilePlugin(),
new webpack.WatchIgnorePlugin([
utils.root('src/test'),
]),
new WebpackNotifierPlugin({
title: 'JHipster',
contentImage: path.join(__dirname, 'logo-jhipster.png')
})
]
});
有人帮助我解决这个问题吗?
答案 0 :(得分:0)
在Web Pack 配置文件
中添加关注代码new CopyWebpackPlugin([
{
from: 'assets/stimulsoft',
to: 'assets/stimulsoft/',
toType: 'dir'
}
])
然后在 index.html
中添加对文件的引用
<link href="assets/stimulsoft/stimulsoft.viewer.office2013.whiteblue.css">
<script type="text/javascript" src="assets/stimulsoft/stimulsoft.reports.js"></script>
<script type="text/javascript" src="assets/stimulsoft/stimulsoft.viewer.js"></script>
<script type="text/javascript" src="assets/stimulsoft/stimulsoft.designer.js"></script>
现在您可以像下面的代码一样在组件中使用
declare var Stimulsoft: any;
@Component({
templateUrl: './reportdesignprint.component.html',
styleUrls: ['./reportdesignprint.component.css'],
})
export class ReportDesignPrintComponent implements OnDestroy, OnInit {
constructor(private _reportSubjectService: ReportSubjectService, private _route: ActivatedRoute, private _router: Router) {
}
ngOnInit(): void {
this.load();
}
ngOnDestroy(): void {
}
load() {
var report = new Stimulsoft.Report.StiReport();
// report.loadFile("SimpleList.mrt");
var designer = new Stimulsoft.Designer.StiDesigner(null, "StiDesigner", false);
// designer.report = report;
designer.renderHtml("designerContent");
}
loadprev() {
var viewer = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false);
// viewer.report = report;
viewer.renderHtml("designerContent");
}
}