Appium 使用./Scripts/bootstrap.sh 命令 build webdriveragent,webpack --progress --colors 报错

卡卡 · March 02, 2017 · Last by 烟消云散 replied at September 27, 2017 · 1564 hits

初学 appium 真机测试,使用./Scripts/bootstrap.sh 命令 build webdriveragent,webpack --progress --colors 报错:

Fetching dependencies
Building Inspector
Creating bundle directory...
Fetching Inspector dependencies...
npm WARN react-treeview@0.4.6 requires a peer of react@>=0.14.0 but none was installed.
npm WARN web-driver-inspector@1.0.0 No repository field.
Building Inspector...

> web-driver-inspector@1.0.0 build /Users/danjiao/node_modules/.2.5.3@appium-xcuitest-driver/WebDriverAgent/Inspector
> webpack --progress --colors

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[0].use should be one of these:
   non-empty string | function | object { loader?, options?, query? } | function | [non-empty string | function | object { loader?, options?, query? }]
   Details:
    * configuration.module.rules[0].use should be a string.
    * configuration.module.rules[0].use should be an instance of function.
    * configuration.module.rules[0].use should be an object.
    * configuration.module.rules[0].use should be one of these:
      non-empty string | function | object { loader?, options?, query? }
    * configuration.module.rules[0].use should be an instance of function.
    * configuration.module.rules[0].use[0] should be a string.
    * configuration.module.rules[0].use[0] should be an instance of function.
    * configuration.module.rules[0].use[0] has an unknown property 'exclude'. These properties are valid:
      object { loader?, options?, query? }
    * configuration.module.rules[0].use[0] should be one of these:
      non-empty string | function | object { loader?, options?, query? }

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! web-driver-inspector@1.0.0 build: `webpack --progress --colors`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the web-driver-inspector@1.0.0 build script 'webpack --progress --colors'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the web-driver-inspector package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack --progress --colors
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs web-driver-inspector
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls web-driver-inspector
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/danjiao/node_modules/.2.5.3@appium-xcuitest-driver/WebDriverAgent/Inspector/npm-debug.log

webpack 版本2.2.1,webpack.config.js文件,自己修改过:
var path = require('path');  
var webpack = require('webpack');  

function buildOutputDir() {
  return (process.env.BUILD_OUTPUT_DIR != null ? process.env.BUILD_OUTPUT_DIR : __dirname);
}

module.exports = {  
  entry: [
    "./js/app.js"
  ],
  output: {
    path: buildOutputDir(),
    filename: "inspector.js"
  },
  module: {
    rules: [
      { test: /\.js?$/, use:[{loader:'babel-loader',exclude:/node_modules/,options:{presets:['es2015']}}]},
      { test: /\.css?$/, loader: 'style-loader!css-loader' },
    ]
  },
  resolve: {
    modules: [path.resolve(__dirname, ''),]
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin()
  ]
};

自己修改过 webpack.config.js,麻烦大家看看对不对,谢谢啦

共收到 1 条回复 时间 点赞

把 /Users/hengjiechen/.nvm/versions/node/v4.2.6/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/webpack.config.js 中的

...
loaders: [
{ test: /.js?$/, loaders: ['babel-loader'], exclude: /node_modules/ },
{ test: /.css?$/, loader: 'style-loader! css-loader' },
]
...
改为

...
loaders: [
{ test: /.js?$/, loaders: ['babel-loader'] },
{ test: /.css?$/, loader: 'style-loader! css-loader' },
]
...
把 , exclude: /node_modules/ 这部分去掉即可。不过我只确定能打包成功,能不能正常运行没试过,你可以试下。

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up