需要帮助为poi项目

时间:2017-12-05 04:09:33

标签: webpack karma-runner

package.json片段

  • poi:9.2.4
  • 业力:^ 1.7.1
  • karma-chai:^ 0.1.0
  • karma-mocha:^ 1.3.0
  • karma-webpack:^ 2.0.6
  • 摩卡:^ 4.0.1
  • poi-preset-karma:^ 9.2.2
  • webpack:^ 3.9.1

poi.config.json

module.exports = {
    presets: [
        require('poi-preset-karma')({
            port: '5050'
        })
    ],
    webpack(config) {
        config.devtool = 'source-map';
        config.watchOptions = {
            ignored: '/node_modules',
            poll: 1000,
        };
        config.stats = {
            depth: true,
            warnings: true,
        };
        return config;
    },
    define: {
        __VERSION__: require('./package.json').version
    },
    html: {
        title: 'Platform',
        template:'index.ejs'
    }
};

当我运行命令 poi test 时,我得到以下输出:

> Using main field in package.json as entry point
> Bundling with Webpack 3.9.1
04 12 2017 22:41:20.194:WARN [config]: "/" is proxied, you should probably change urlRoot to avoid conflicts
TypeError: Cannot read property 'type' of undefined
    at Function.formatSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:83:13)
    at formatInnerSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:78:54)
    at Function.formatSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:106:15)
    at getSchemaPartText (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:36:49)
    at Function.formatValidationError (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:188:49)
    at WebpackOptionsValidationError.message.Invalid configuration object. .Webpack has been initialised using a configuration object that does not match the API schema.
.validationErrors.map.err (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:68:77)
    at Array.map (<anonymous>)
    at new WebpackOptionsValidationError (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:68:21)
    at webpack (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/webpack.js:19:9)
    at Plugin (/home/rshighto/btg/peeprFrontend/node_modules/karma-webpack/lib/karma-webpack.js:67:16)
    at invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:75:15)
    at Array.instantiate (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:59:20)
    at get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at /home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Array.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:70:31)
    at Injector.get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at instantiatePreprocessor (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/preprocessor.js:55:20)
    at Array.forEach (<anonymous>)
    at createPreprocessor (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/preprocessor.js:74:20)
    at Array.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:75:15)
    at get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at /home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Injector.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:70:31)
    at Server.start (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/server.js:103:18)
    at Ware.poi.run.webpackConfig (/home/rshighto/btg/peeprFrontend/node_modules/poi-preset-karma/index.js:133:14)
    at Ware.<anonymous> (/home/rshighto/btg/peeprFrontend/node_modules/wrap-fn/index.js:75:16)
04 12 2017 22:41:21.406:ERROR [preprocess]: Can not load "webpack"!
  TypeError: Cannot read property 'type' of undefined
    at Function.formatSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:83:13)
    at formatInnerSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:78:54)
    at Function.formatSchema (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:106:15)
    at getSchemaPartText (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:36:49)
    at Function.formatValidationError (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:188:49)
    at WebpackOptionsValidationError.message.Invalid configuration object. .Webpack has been initialised using a configuration object that does not match the API schema.
.validationErrors.map.err (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:68:77)
    at Array.map (<anonymous>)
    at new WebpackOptionsValidationError (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/WebpackOptionsValidationError.js:68:21)
    at webpack (/home/rshighto/btg/peeprFrontend/node_modules/webpack/lib/webpack.js:19:9)
    at Plugin (/home/rshighto/btg/peeprFrontend/node_modules/karma-webpack/lib/karma-webpack.js:67:16)
    at invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:75:15)
    at Array.instantiate (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:59:20)
    at get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at /home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Array.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:70:31)
    at Injector.get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at instantiatePreprocessor (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/preprocessor.js:55:20)
    at Array.forEach (<anonymous>)
    at createPreprocessor (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/preprocessor.js:74:20)
    at Array.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:75:15)
    at get (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:48:43)
    at /home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Injector.invoke (/home/rshighto/btg/peeprFrontend/node_modules/di/lib/injector.js:70:31)
    at Server.start (/home/rshighto/btg/peeprFrontend/node_modules/karma/lib/server.js:103:18)
    at Ware.poi.run.webpackConfig (/home/rshighto/btg/peeprFrontend/node_modules/poi-preset-karma/index.js:133:14)
    at Ware.<anonymous> (/home/rshighto/btg/peeprFrontend/node_modules/wrap-fn/index.js:75:16)

START:
04 12 2017 22:41:21.653:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:5050/
04 12 2017 22:41:21.654:INFO [launcher]: Launching browser Chrome with unlimited concurrency
04 12 2017 22:41:21.656:ERROR [karma]: Found 1 load error

我尝试查看一些webpack代码,看看有什么遗漏,但我不确定。似乎问题是webpack期望至少定义一个模式选项,但事实并非如此。我尝试在POI的开发者网站https://poi.js.org/#/上查看示例,但找不到任何内容。

任何人都知道之前缺少什么或遇到过这个问题?

1 个答案:

答案 0 :(得分:0)

我终于能够解决问题了。想我真的没有对karma-webpack的依赖。所以我删除了它,删除了node_modules /并清除了我的本地缓存。为了安全起见,我从节点9.0.0降级到8.9.1(lts)。