Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安装完脚手架,开发运行报错 #12

Closed
ChasonHong opened this issue Dec 12, 2018 · 9 comments
Closed

安装完脚手架,开发运行报错 #12

ChasonHong opened this issue Dec 12, 2018 · 9 comments

Comments

@ChasonHong
Copy link

webpack不是4.0以上吗?

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration has an unknown property '1'. These properties are valid:
    object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }
    For typos: please correct them.
    For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
    Loaders should be updated to allow passing options via loader options in module.rules.
    Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
    plugins: [
    new webpack.LoaderOptionsPlugin({
    // test: /.xxx$/, // may apply this only for some modules
    options: {
    1: …
    }
    })
    ]
    at webpack (/Users/chason/Desktop/mpx/node_modules/webpack/lib/webpack.js:31:9)
    at runWebpack (/Users/chason/Desktop/mpx/build/build.js:30:5)
    at err (/Users/chason/Desktop/mpx/build/build.js:58:3)
    at afterGlob (/Users/chason/Desktop/mpx/node_modules/rimraf/rimraf.js:84:14)
    at f (/Users/chason/Desktop/mpx/node_modules/once/once.js:25:25)
    at Glob. (/Users/chason/Desktop/mpx/node_modules/glob/glob.js:151:7)
    at Glob.emit (events.js:182:13)
    at Glob._finish (/Users/chason/Desktop/mpx/node_modules/glob/glob.js:197:8)
    at done (/Users/chason/Desktop/mpx/node_modules/glob/glob.js:182:14)
    at Glob._processReaddir2 (/Users/chason/Desktop/mpx/node_modules/glob/glob.js:408:12)
    at /Users/chason/Desktop/mpx/node_modules/glob/glob.js:371:17
    at RES (/Users/chason/Desktop/mpx/node_modules/inflight/inflight.js:31:16)
    at f (/Users/chason/Desktop/mpx/node_modules/once/once.js:25:25)
    at Glob._readdirEntries (/Users/chason/Desktop/mpx/node_modules/glob/glob.js:578:10)
    at /Users/chason/Desktop/mpx/node_modules/glob/glob.js:555:12
    at FSReqWrap.oncomplete (fs.js:141:20)
@sky-admin
Copy link
Collaborator

发下你的webpack config?cli创建项目时是一路回车下来的吗?

@hiyuki
Copy link
Collaborator

hiyuki commented Dec 12, 2018

检查一下是不是手动往配置里敲了一个‘1’,脚手架生成的配置中不应该存在这种属性

@loo41
Copy link

loo41 commented Dec 12, 2018

  • 项目运行报错
  • 模板配置错了
  • 数组和对象 merge 成了下标对象这种形式去了
function runWebpack (cfg) {
  if (program.production || program.watch) {
    cfg = merge(cfg, program.production ? {
      mode: 'production'
    } : {
      cache: true
    })
  }
  if (process.env.npm_config_report) {
    var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
    var mainCfg = Array.isArray(cfg) ? cfg[0] : cfg
    mainCfg.plugins.push(new BundleAnalyzerPlugin())
  }
  if (program.watch) {
    【console.log(cfg)】
    webpack(cfg).watch({}, callback)
  } else {
    webpack(cfg, callback)
  }
}

得到

{ '0':
   { module: { rules: [Array] },
     output:
      { filename: '[name].js',
        path: 'D:\\桌面-copy\\mpxtest\\dist\\plugin' },
     optimization: { runtimeChunk: [Object], splitChunks: [Object] },
     mode: 'none',
     plugins: [ [Object] ],
     resolve: { extensions: [Array], modules: [Array] },
     entry: { plugin: 'D:\\桌面-copy\\mpxtest\\src\\plugin\\plugin.json' } },
  '1':
   { module: { rules: [Array] },
     output:
      { filename: '[name].js',
        path: 'D:\\桌面-copy\\mpxtest\\dist\\miniprogram' },
     optimization: { runtimeChunk: [Object], splitChunks: [Object] },
     mode: 'none',
     plugins: [ [Object], [Object] ],
     resolve: { extensions: [Array], modules: [Array] },
     entry: { app: 'D:\\桌面-copy\\mpxtest\\src\\miniprogram\\app.mpx' } },
  cache: true }

@nan1010082085
Copy link

npm run watch报错了? 为啥npm run build命令是好的呢

@nan1010082085
Copy link

@sky-admin @loo41 大佬有正确的模版配置吗

@loo41
Copy link

loo41 commented Dec 12, 2018

因为build并没有执行这个

 cfg = merge(cfg, program.production ? {
      mode: 'production'
    } : {
      cache: true
    })

@nan1010082085
Copy link

我重新下生成了一下项目 发现 一路回车 在plugins 插件这个选项的时候选择 no 生成的命令
也就是不是插件模式 npm run warch 就没问题

@sky-admin
Copy link
Collaborator

已复现问题,正在解决,正常开发需求一般应该选择非插件模式,我们默认提供的选项也是No。。

@sky-admin
Copy link
Collaborator

已解决。重新init项目即可。
已有项目的修改可参见:mpx-ecology/mpx-template@5d8ce0c

hiyuki pushed a commit that referenced this issue Jun 27, 2024
fix: 修复多个style动态化收集信息时,style覆盖内容的问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants