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/[email protected] 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.
Could you try the same with webpack-cli@beta?
I had a similar issue on Node 10.17.0. It worked for me after I downgraded to 10.15.3
Could you try the same with webpack-cli@beta?
The following command was executed.
yarn add --dev webpack webpack-cli@beta @webpack-cli/init @webpack-cli/info
However, another error occurs and it does not work.
xuser@x-macbook-pro β test3 yarn run webpack-cli init
yarn run v1.19.1
$ /Users/xuser/works/jsworks/virtual-dom/test3/node_modules/.bin/webpack-cli init
(node:77940) [DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK] DeprecationWarning: MainTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)
(node:77940) [DEP_WEBPACK_CHUNK_TEMPLATE_HASH_FOR_CHUNK] DeprecationWarning: ChunkTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)
β
Compilation Results
π Version: 5.0.0-beta.7
βοΈ Built: Mon Nov 25 2019 11:00:03 GMT+0900 (GMT+09:00)
β± Compile Time: 417ms
π Output Directory: /Users/xuser/works/jsworks/virtual-dom/test3/dist
βββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββ
β Build Status β Bundle Name β Bundle Size β
βββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββ€
β failed β main.js β 0 kb β
βββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββ
β¬’ webpack: configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
β¬’ webpack: NoModeWarning: configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
at compiler.hooks.thisCompilation.tap.compilation (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/WarnNoModeSetPlugin.js:20:30)
at Hook.eval [as call] (eval at create (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/HookCodeFactory.js:19:10), <anonymous>:13:1)
at Hook.CALL_DELEGATE [as _call] (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/Hook.js:14:14)
at Compiler.newCompilation (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:857:30)
at hooks.beforeCompile.callAsync.err (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:898:29)
at Hook.eval [as callAsync] (eval at create (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/Hook.js:18:14)
at Compiler.compile (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:893:28)
at readRecords.err (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:424:12)
at Compiler.readRecords (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:736:11)
at hooks.run.callAsync.err (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:421:11)
at Hook.eval [as callAsync] (eval at create (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/Hook.js:18:14)
at hooks.beforeRun.callAsync.err (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/webpack/lib/Compiler.js:418:20)
at Hook.eval [as callAsync] (eval at create (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/xuser/works/jsworks/virtual-dom/test3/node_modules/webpack-cli/node_modules/xpable/lib/Hook.js:18:14)
β¬’ webpack: Module not found: Error: Can't resolve './src' in '/Users/xuser/works/jsworks/virtual-dom/test3'
β¨ Done in 2.30s.
I am also using [email protected].
xuser@x-macbook-pro β test3 cat package.json
{
"name": "test3",
"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": "^4.0.0-beta.1"
}
}
xuser@x-macbook-pro β test3 node -v
v10.17.0
Thank you.
I also tried [email protected] but it seems to be no good as well. @webpack-cli/[email protected]
I use @webpack-cli/[email protected]which is fine for now.
yarn add --dev webpack webpack-cli @webpack-cli/[email protected]
node -v
v12.13.1
Thank you.
Thx for the feedback!
Hi @vertuxx thanks for reporting error.
v0.3.0 was launched from next branch without beta tag.webpack-cli v4, we have renamed init to createv0.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
Add npx against commands if CLI is installed locally
@rishabh3112 if im use webpack-cli@beta create work but im have the following error when use npm run build
β¬’ webpack: ValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.optimization.splitChunks should be one of these:
false | object { automaticNameDelimiter?, cacheGroups?, chunks?, fallbackCacheGroup?, filename?, hidePathInfo?, maxAsyncRequests?, maxAsyncSize?, maxInitialRequests?, maxInitialSize?, maxSize?, minChunks?, minRemainingSize?, minSize?, name? }
-> Optimize duplication and caching by splitting chunks by shared modules and cache group
Details:
* configuration.optimization.splitChunks.name should be one of these:
false | function | string
-> Give chunks created a name (chunks with equal name are merged)
Details:
* configuration.optimization.splitChunks.name should be false.
* configuration.optimization.splitChunks.name should be an instance of function.
* configuration.optimization.splitChunks.name should be a string.
@dictateurfou
This error seems to be due to error in the configuration. Refer following steps:
webpack v5, refer Migration Guide to update the scaffolded configuration.webpack v4, use webpack-cli v3, @webpack-cli/init v0.2.2.Same here. None of these ways work:
npx webpack-cli init
init isn't a valid name.
It should be prefixed with 'webpack-scaffold', but have different suffix.
β patch-cutter-browser git:(master) β rm -rf node_modules
β patch-cutter-browser git:(master) β npx webpack-cli init
npx: Installierte 204 in 9.322s
The command moved into a separate package: @webpack-cli/init
Would you like to install init? (That will run yarn global add @webpack-cli/init) (yes/NO) : yes
yarn global v1.19.1
[1/4] π Resolving packages...
[2/4] π Fetching packages...
[3/4] π Linking dependencies...
warning "@webpack-cli/init > @webpack-cli/[email protected]" has unmet peer dependency "[email protected]".
warning "@webpack-cli/init > @webpack-cli/generators > [email protected]" has unmet peer dependency "inquirer@^5.0.0 || ^6.0.0".
[4/4] π¨ Building fresh packages...
warning "@webpack-cli/[email protected]" has no binaries
β¨ Done in 5.14s.
{ Error: Cannot find module '/Users/danielruf/.nodenv/versions/10.16.3/lib/node_modules/@webpack-cli/init'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/danielruf/.npm/_npx/3622/lib/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at npmGlobalRoot.then.then.pathForInit (/Users/danielruf/.npm/_npx/3622/lib/node_modules/webpack-cli/bin/utils/prompt-command.js:114:18)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
* For `webpack-cli` v4, we have renamed `init` to `create`
Well, this is a breaking change and not reflected in the 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/[email protected] and npx webpack-cli init worked.
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.
I'm sorry, but how come that on a clean project npx webpack-cli init (that is in the docs everywhere, from https://webpack.js.org/configuration/ to https://github.com/webpack/webpack-cli/) doesn't run well?
npx: installed 204 in 23.624s
init isn't a valid name.
It should be prefixed with 'webpack-scaffold', but have different suffix.
I had to run npm i -D @webpack-cli/[email protected] before npx webpack-cli init as adviced here.
Could something be wrong with my setup (but as I said, I have a clean project, and nothing in my environment seems unusual) since I don't see a lot of feedback here, and if not, is anybody going to do anything about it? Running into errors on a default setup doesn't seem good.
Hi all, pls help.
I have npm v6.13.4, node v12.14.1.
When i create new project, i use this steps (i use VSCode and is one empty folder.):
npm init -y (to create file pakage.json)npm install webpack webpack-cli --save-dev.node_modules\.bin\webpack-cli init --auto, and i have crated project struct, but without file "webpack.config.js" Why? What i do wrong? I dont whant to downgrade to "@webpack-cli/[email protected]"!
Hi @RVyrvin,
Please open a new issue.
Also see the previous replies.
@webpack-cli/[email protected]
Try npm i @webpack-cli/[email protected] --save-dev.
webpack.config.js
So you mean the file is not generated? webpack 4 does not require a config by default. Try it without the --auto option.
Hi, ty for answer.
without --auto dont work.
And yes, now i need self create webpack.config.js.
El SΓ‘b 18/01/2020, 12:39, Daniel Ruf notifications@github.com escribiΓ³:
webpack.config.js
So you mean the file is not generated? webpack 4 does not require a config
by default. Try it without the --auto option.β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/webpack/webpack-cli/issues/1127?email_source=notifications&email_token=AKFTPSCBSZ63LW4RK6XJ7J3Q6LS57A5CNFSM4JPPAHI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJWNGA#issuecomment-575891096,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AKFTPSAONV3QQDNZIOEYUGTQ6LS57ANCNFSM4JPPAHIQ
.
Please check the readme and the previous replies, --init should work.
Is it supposed to generate a webpack.config.js file?
Here are the files generated using ./node_modules/.bin/webpack-cli init --auto:
node --version
v13.6.0
npm --version
6.13.6
On branch master No commits yet Untracked files: (use "git add..." to include in what will be committed) .yo-rc.json README.md index.html node_modules/ package-lock.json package.json src/ nothing added to commit but untracked files present (use "git add" to track)
package.json
{
"name": "tryinit",
"version": "1.0.0",
"description": "My webpack project",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"start": "webpack-dev-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@webpack-cli/init": "^0.3.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"html-webpack-plugin": "^3.2.0",
"terser-webpack-plugin": "^2.3.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1",
"workbox-webpack-plugin": "^4.3.1"
}
}
node_modules/.bin/webpack-cli init --init # produces error
/home/aes/Sandbox/webpack/tryinit/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 /home/aes/Sandbox/webpack/tryinit/node_modules/@webpack-cli/utils/npm-packages-exists.js:42:19
at Array.forEach ()
at Object.npmPackagesExists [as default] (/home/aes/Sandbox/webpack/tryinit/node_modules/@webpack-cli/utils/npm-packages-exists.js:26:9)
at initializeInquirer (/home/aes/Sandbox/webpack/tryinit/node_modules/@webpack-cli/init/index.js:23:41)
at runWhenInstalled (/home/aes/Sandbox/webpack/tryinit/node_modules/webpack-cli/bin/utils/prompt-command.js:46:9)
at promptForInstallation (/home/aes/Sandbox/webpack/tryinit/node_modules/webpack-cli/bin/utils/prompt-command.js:140:10)
at /home/aes/Sandbox/webpack/tryinit/node_modules/webpack-cli/bin/cli.js:32:43
at Object. (/home/aes/Sandbox/webpack/tryinit/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
P.S. How to make use of the .yo-rc.json?
TypeError: init isn't a valid name.
It should be prefixed with 'webpack-scaffold', but have different suffix.
Please see the previous comments and the readme in the repository. By default webpack does not need a config anymore (0 config) unless you want to change the defaults.
Hi.
So "node_modulos/.bin/webpack-cli init --auto" create struct of project,
and don't create "webpack.config.js".
I understand with this file when i run "npm run build/start", dont run
application on the browser?
Now, i need to create "webpack.config.js" by self or i can create him
automaticaly?
Sorry my english and ty for help me.
El dom., 19 ene. 2020 a las 10:00, Daniel Ruf (notifications@github.com)
escribiΓ³:
TypeError: init isn't a valid name.
It should be prefixed with 'webpack-scaffold', but have different suffix.
Please see the previous comments and the readme in the repository. By
default webpack does not need a config anymore (0 config) unless you want
to change the defaults.β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/webpack/webpack-cli/issues/1127?email_source=notifications&email_token=AKFTPSHEL3Q5QT7WFGPQPZLQ6QJCRA5CNFSM4JPPAHI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJKMUAA#issuecomment-575982080,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AKFTPSH2MXXR2NLVWW2Q273Q6QJCRANCNFSM4JPPAHIQ
.
@RVyrvin you don't need to create a configuration file, webpack has its own defaults now.
If you need to add particular configuration, plugin, etc. you'd need to create yourself or use a scaffold
For webpack-cli v4, we have renamed init to create
@ematipico Should I make a PR for this to be reflected in docs?
No we are back to init again.
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.
Uh, what? So you changed back? Is there additional information @snitin315?
There is no such additional info.
Also why the "thumbs down" reaction? A simple "no we need no PR because ..." is sufficient.
Just in support of my comment.
No we are back to init again.
@snitin315 But I am still getting the same error.
Init isn't a valid name.
Against Beta?
works fine for me.

I am still getting the following error.
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 (/home/phoenix/Desktop/temp2/node_modules/@webpack-cli/utils/npm-packages-exists.js:42:19)
at Array.forEach (<anonymous>)
at Object.npmPackagesExists [as default] (/home/phoenix/Desktop/temp2/node_modules/@webpack-cli/utils/npm-packages-exists.js:26:9)
at initializeInquirer (/home/phoenix/Desktop/temp2/node_modules/@webpack-cli/init/index.js:23:41)
at runWhenInstalled (/home/phoenix/Desktop/temp2/node_modules/webpack-cli/bin/utils/prompt-command.js:46:9)
at promptForInstallation (/home/phoenix/Desktop/temp2/node_modules/webpack-cli/bin/utils/prompt-command.js:140:10)
at /home/phoenix/Desktop/temp2/node_modules/webpack-cli/bin/cli.js:32:43
at Object.<anonymous> (/home/phoenix/Desktop/temp2/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
and output of npx webpack-cli info is
System:
OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 2.95 GB / 7.66 GB
Binaries:
Node: 10.15.2 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 5.8.0 - /usr/bin/npm
Browsers:
Chrome: 80.0.3987.149
Firefox: 68.6.0esr
npmPackages:
webpack-cli: ^3.3.11 => 3.3.11
You are using version 3, please try with beta once.
Yes, it worked. But i have a question that because [email protected] version is being shipped through yarn or npm and also init is not working as expected with it. Can't we provide some documentation or a little help tips somewhere so that people facing this issue for first time don't get scared @snitin315 ?
I'm not sure refer this comment.
Also what changes in docs do you suggest?
There is no such additional info.
There is definitely a commit for this (reverted) change and a PR ;-)
Finally, it works with webpack-cli init if
"devDependencies": {
"webpack": "^4.43.0",
"webpack-cli": "^4.0.0-beta.8"
}
because, default install does not work π
Hey if we need to npm i -D @webpack-cli/[email protected] before npx webpack-cli init now, can someone update the outdated instructions here? Can confirm this was required on a clean project.
https://webpack.js.org/configuration/
/cc @webpack/cli-team Just clarify, have we test on this stuff?
Let's close, I think the problem fixed, feel free to open a new issue if you faced with issue again
Most helpful comment
Well, this is a breaking change and not reflected in the docs.