Skip to content

Unable to load '@webpack-cli/serve' command. TypeError: devServerFlags is not iterable #1069

@nspyke

Description

@nspyke

After upgrading from v1.5 to v1.7 I get the following error when running encore dev-server

$ npx encore dev-server
Running webpack-dev-server ...

[webpack-cli] Unable to load '@webpack-cli/serve' command
[webpack-cli] TypeError: devServerFlags is not iterable
    at /home/nik/dev/fleetman-app/node_modules/@webpack-cli/serve/lib/index.js:28:43
    at WebpackCLI.makeCommand (/home/nik/dev/fleetman-app/node_modules/webpack-cli/lib/webpack-cli.js:104:31)
    at ServeCommand.apply (/home/nik/dev/fleetman-app/node_modules/@webpack-cli/serve/lib/index.js:10:19)
    at loadCommandByName (/home/nik/dev/fleetman-app/node_modules/webpack-cli/lib/webpack-cli.js:626:35)
    at Command.<anonymous> (/home/nik/dev/fleetman-app/node_modules/webpack-cli/lib/webpack-cli.js:1091:23)
    at Command.listener [as _actionHandler] (/home/nik/dev/fleetman-app/node_modules/webpack-cli/node_modules/commander/index.js:922:31)
    at Command._parseCommand (/home/nik/dev/fleetman-app/node_modules/webpack-cli/node_modules/commander/index.js:1503:14)
    at Command.parse (/home/nik/dev/fleetman-app/node_modules/webpack-cli/node_modules/commander/index.js:1292:10)
    at Command.parseAsync (/home/nik/dev/fleetman-app/node_modules/webpack-cli/node_modules/commander/index.js:1318:10)
    at WebpackCLI.run (/home/nik/dev/fleetman-app/node_modules/webpack-cli/lib/webpack-cli.js:1123:28)

My webpack.config.js file is

const Encore = require('@symfony/webpack-encore')
const MomentLocalesPlugin = require('moment-locales-webpack-plugin')

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
  Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev')
}

Encore
  // directory where compiled assets will be stored
  .setOutputPath('public/build/')
  // public path used by the web server to access the output path
  .setPublicPath('/build')
  // only needed for CDN's or sub-directory deploy
  // .setManifestKeyPrefix('build/')

  /*
   * ENTRY CONFIG
   *
   * Each entry will result in one JavaScript file (e.g. app.js)
   * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
   */
  .addEntry('app', './assets/modules/app/index.ts')
  .addEntry('admin', './assets/modules/admin/index.ts')
  .addEntry('user', './assets/modules/user/index.ts')
  .addStyleEntry('email', './assets/modules/email/index.scss')
  .addStyleEntry('print', './assets/modules/print/index.scss')

  // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
  .enableStimulusBridge('./assets/controllers.json')

  // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
  .splitEntryChunks()

  // will require an extra script tag for runtime.js
  // but, you probably want this, unless you're building a single-page app
  .enableSingleRuntimeChunk()

  /*
   * FEATURE CONFIG
   *
   * Enable & configure other features below. For a full
   * list of features, see:
   * https://symfony.com/doc/current/frontend.html#adding-more-features
   */
  .cleanupOutputBeforeBuild()
  .enableBuildNotifications()
  .enableSourceMaps(!Encore.isProduction())

  // Enables Sass/SCSS support
  .enableSassLoader()

  // Enable PostSCSS support
  .enablePostCssLoader()

  // Enable TypeScript
  .enableTypeScriptLoader()

  // Enable Vue
  .enableVueLoader(() => {}, { runtimeCompilerBuild: true })

  // Enable hashed filenames (e.g. app.abc123.css)
  .enableVersioning(Encore.isProduction())

  // applies integrity="..." attributes on your script & link tags
  .enableIntegrityHashes(Encore.isProduction())

  .configureBabel((config) => {
    config.plugins.push('@babel/plugin-proposal-class-properties')
  })

  // enables @babel/preset-env polyfills
  .configureBabelPresetEnv((config) => {
    config.useBuiltIns = 'usage'
    config.corejs = 3
  })

  .autoProvidejQuery()
  .addPlugin(new MomentLocalesPlugin())

module.exports = Encore.getWebpackConfig()

Both dev and prod builds work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions