webpack-cli: [BUG]: @webpack-cli/init@0.3.0 does not work

Describe the bug

An error occurs when you run the webpack-cli init command.

What is the current behavior?

To Reproduce

yarn add --dev webpack webpack-cli @webpack-cli/init
yarn run webpack-cli init

Expected behavior The webpack-cli init command works correctly.

Screenshots N/A

Please paste the results of webpack-cli info here, and mention other relevant information

x-macbook-pro:test2 xuser$ yarn run webpack-cli info
yarn run v1.19.1
$ /Users/xuser/works/jsworks/virtual-dom/test2/node_modules/.bin/webpack-cli info
undefined

  System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
    Memory: 617.09 MB / 16.00 GB
  Binaries:
    Node: 10.16.3 - /var/folders/4j/7cl0sfxj4dv77hkj40xf9x340000gn/T/yarn--1574233136999-0.305712911277922/node
    Yarn: 1.19.1 - /var/folders/4j/7cl0sfxj4dv77hkj40xf9x340000gn/T/yarn--1574233136999-0.305712911277922/yarn
    npm: 6.9.0 - ~/.nodebrew/current/bin/npm
  Browsers:
    Chrome: 78.0.3904.97
    Firefox: 70.0.1
    Safari: 13.0.1
  npmPackages:
    webpack: ^4.41.2 => 4.41.2 
    webpack-cli: ^3.3.10 => 3.3.10 

Additional context

x-macbook-pro:test2 xuser$ yarn run webpack-cli init
yarn run v1.19.1
$ /Users/xuser/works/jsworks/virtual-dom/test2/node_modules/.bin/webpack-cli init
/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/@webpack-cli/utils/npm-packages-exists.js:42
            throw new TypeError(chalk_1.default.bold(`${scaffold} isn't a valid name.\n`) +
            ^

TypeError: init isn't a valid name.

It should be prefixed with 'webpack-scaffold', but have different suffix.

    at pkg.forEach (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/@webpack-cli/utils/npm-packages-exists.js:42:19)
    at Array.forEach (<anonymous>)
    at Object.npmPackagesExists [as default] (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/@webpack-cli/utils/npm-packages-exists.js:26:9)
    at initializeInquirer (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/@webpack-cli/init/index.js:23:41)
    at runWhenInstalled (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/webpack-cli/bin/utils/prompt-command.js:46:9)
    at promptForInstallation (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/webpack-cli/bin/utils/prompt-command.js:140:10)
    at /Users/xuser/works/jsworks/virtual-dom/test2/node_modules/webpack-cli/bin/cli.js:32:43
    at Object.<anonymous> (/Users/xuser/works/jsworks/virtual-dom/test2/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

package.json

x-macbook-pro:test2 xuser$ cat package.json 
{
  "name": "test2",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@webpack-cli/info": "^0.2.0",
    "@webpack-cli/init": "^0.3.0",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10"
  }
}

@webpack-cli/init@0.2.2 is works fine.

{
  "name": "test1",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@webpack-cli/info": "^0.2.0",
    "@webpack-cli/init": "0.2.2",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10"
  }
}

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 14
  • Comments: 39 (26 by maintainers)

Most upvoted comments

* For `webpack-cli` v4, we have renamed `init` to `create`

Well, this is a breaking change and not reflected in the docs.

Tested npx webpack-cli init --auto based on the docs https://github.com/webpack/webpack-cli/blob/next/packages/init/README.md#webpack-cli-init and it works for v0.3.0.

@dictateurfou This error seems to be due to error in the configuration. Refer following steps:

  1. If you are using webpack v5, refer Migration Guide to update the scaffolded configuration.
  2. If you are using webpack v4, use webpack-cli v3, @webpack-cli/init v0.2.2.

Hi @vertuxx thanks for reporting error.

  • v0.3.0 was launched from next branch without beta tag.
  • For webpack-cli v4, we have renamed init to create
  • v0.3.0 should work with following commands with webpack-cli@beta:
webpack-cli create
webpack-cli create webpack-scaffold-pwa #example with custom scaffold

cc @evenstensberg

Uh, what? So you changed back? Is there additional information @snitin315?

https://github.com/webpack/webpack-cli/issues/1127#issuecomment-562989705

Also why the “thumbs down” reaction? A simple “no we need no PR because …” is sufficient.

For webpack-cli v4, we have renamed init to create

@ematipico Should I make a PR for this to be reflected in docs?

@dictateurfou This error seems to be due to error in the configuration. Refer following steps:

1. If you are using `webpack v5`, refer [Migration Guide](https://github.com/webpack/changelog-v5/blob/master/MIGRATION%20GUIDE.md) to update the scaffolded configuration.

2. If you are using `webpack v4`, use `webpack-cli v3`, `@webpack-cli/init v0.2.2`.

Thanks, i used npm install -D @webpack-cli/init@0.2.2 and npx webpack-cli init worked.