Describe the bug
package.json with content
...
"devDependencies": {
"@webpack-cli/generate-plugin": "0.0.8",
"@webpack-cli/init": "^0.1.0",
"@webpack-cli/migrate": "^0.1.0",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0"
},
...
What is the current behavior?
TypeError: require(...).default is not a function
at promptForInstallation (/Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/webpack-cli/bin/prompt-command.js:108:30)
at /Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/webpack-cli/bin/cli.js:45:37
at Object.<anonymous> (/Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/webpack-cli/bin/cli.js:530:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
To Reproduce
} else {
require(pathForCmd)(...args); // eslint-disable-line
}
Expected behavior
only my-webpack-plugin create.
Screenshots

System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Binaries:
Node: 8.11.1 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.2.0 - /usr/local/bin/npm
Browsers:
Chrome: 68.0.3440.106
Firefox: 54.0
Safari: 11.1.2
npmPackages:
webpack: ^4.17.1 => 4.17.1
webpack-cli: ^3.1.0 => 3.1.0
webpack-defaults: ^2.3.0 => 2.3.0
npmGlobalPackages:
webpack-cli: 3.1.0
webpack: 4.17.1
Additional context
Add any other context about the problem here like linking to an similar issue you might think is the cause.
@dhruvdutt do you mind fixing this?
This is happening because you have older version of "@webpack-cli/generate-plugin": "0.0.8" which is incompatible with the current version of webpack-cli.
Can you please upgrade to latest version 0.1.0 of @webpack-cli/generate-plugin?
@ematipico you are right. thank you.
sorry, my npm registry is https://registry.npm.taobao.org/. I do cnpm sync webpack-cli @webpack-cli/generate-plugin.
npm install @webpack-cli/[email protected]`, it works, but with error
➜ webpack-plugin-demo git:(master) ✗ npx webpack-cli generate-plugin
? Plugin name my-1
Your project must be inside a folder named my-1
I will create this folder for you.
Failed to create directory null
events.js:183
throw er; // Unhandled 'error' event
^
AssertionError [ERR_ASSERTION]: Trying to copy from a source that does not exist: /Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/@webpack-cli/generate-plugin/test/test-utils.js.tpl
I copy the miss files in the repository https://github.com/webpack/webpack-cli/tree/master/packages/generate-plugin. It can work. but will do scripts webpack-defaults, it's default config ?
npm WARN deprecated @types/[email protected]: This is a stub types definition for commander (https://github.com/tj/commander.js). commander provides its own type definitions, so you don't need @types/commander installed!
> [email protected] postinstall /Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/webpack-defaults
> node lib/post_install.js
Update /Users/huixisheng/x/lab/webpack/webpack-plugin-demo/package.json
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
+ [email protected]
+ [email protected]
added 1 package from 1 contributor, removed 4 packages and updated 1 package in 13.647s
> [email protected] defaults /Users/huixisheng/x/lab/webpack/webpack-plugin-demo
> webpack-defaults
Synchronizing config files...
Create .babelrc
Create codecov.yml
Create .eslintignore
Create .gitignore
Create .gitattributes
Create .github/ISSUE_TEMPLATE.md
I try to install @webpack-cli/[email protected]. but Can't find package @webpack-cli/generate-plugin@^0.1.0.


I will do with npm cache verify, yarn cache clean in the process.
https://www.npmjs.com/package/@webpack-cli/generate-plugin
It looks like it's there. Are you hitting the correct registry?
Seems like we might need to support China ( Tabao ) as well. Makes sense?
Yes
@huixisheng We're identified and resolved the issue. We'll soon release a new version with the fix.
👍
but will do scripts webpack-defaults, it's default config ?
npm WARN deprecated @types/[email protected]: This is a stub types definition for commander (https://github.com/tj/commander.js). commander provides its own type definitions, so you don't need @types/commander installed!
> [email protected] postinstall /Users/huixisheng/x/lab/webpack/webpack-plugin-demo/node_modules/webpack-defaults
> node lib/post_install.js
Could you elaborate @huixisheng ?
The generated files are all redundant except my-webpack-plugin folder ?

I don't think I understand your question. Are you trying to run webpack-defaults and you are wondering if it is ok to run it through webpack-cli?
I came across the same issue, this is properly a fix:
} else {
let p = require(pathForCmd), c = p[packages];
if (typeof c !== 'function' && typeof p.default === 'function') {
c = p.default;
}
c(...args); // eslint-disable-line
}
which replaced the original (prompt-command.js):
} else {
require(pathForCmd).default(...args); // eslint-disable-line
}
the strange things in this fix is about packages -- if it's not indicating the sub-command.
Maybe you can do a PR to fix this? That would be great 🤗😍
Maybe you can do a PR to fix this? That would be great
https://github.com/webpack/webpack-cli/compare/master...duzy:patch-1