Skip to content

bug: require(...).default is not a function #572

@huixisheng

Description

@huixisheng

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

  1. npx webpack-cli generate-plugin
  2. vi remote default
	} else {
		require(pathForCmd)(...args); // eslint-disable-line
	}

Expected behavior

only my-webpack-plugin create.

Screenshots

image

  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions