ant-design-pro: ๐Ÿ› [BUG]pro create myapp fail

๐Ÿ› bug ๆ่ฟฐ

/usr/local/lib/node_modules/@ant-design/pro-cli/src/create/generators/ant-design-pro/index.js:10
const sortPackage = require('sort-package-json');
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/@ant-design/pro-cli/node_modules/sort-package-json/index.js from /usr/local/lib/node_modules/@ant-design/pro-cli/src/create/generators/ant-design-pro/index.js not supported.
Instead change the require of /usr/local/lib/node_modules/@ant-design/pro-cli/node_modules/sort-package-json/index.js in /usr/local/lib/node_modules/@ant-design/pro-cli/src/create/generators/ant-design-pro/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/usr/local/lib/node_modules/@ant-design/pro-cli/src/create/generators/ant-design-pro/index.js:10:21)
    at /usr/local/lib/node_modules/@ant-design/pro-cli/src/create/index.js:15:23
    at new Promise (<anonymous>)
    at runGenerator (/usr/local/lib/node_modules/@ant-design/pro-cli/src/create/index.js:8:10)
    at run (/usr/local/lib/node_modules/@ant-design/pro-cli/src/create/index.js:35:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/@ant-design/pro-cli/cli.js:60:34) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v19.4.0

๐Ÿ“ท ๅค็Žฐๆญฅ้ชค | Recurrence steps

pro create myapp

๐Ÿž ๆœŸๆœ›็ป“ๆžœ | Expected results

ยฉ ็‰ˆๆœฌไฟกๆฏ

  • Ant Design Pro ็‰ˆๆœฌ: latest
  • umi ็‰ˆๆœฌ
  • ๆต่งˆๅ™จ็Žฏๅขƒ
  • ๅผ€ๅ‘็Žฏๅขƒ macOS

๐Ÿš‘ ๅ…ถไป–ไฟกๆฏ

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 32

Most upvoted comments

npm i @ant-design/pro-cli -g ่ฟ›ๅ…ฅ@ant-design/pro-cli ็›ฎๅฝ•ไธญ npm i sort-package-json@1.55.0 -D ้‡ๆ–ฐๅˆ›ๅปบ้กน็›ฎpro create my-app image

I got the same error

Same error

Update: step1.open ant-design folder cd /usr/local/lib/node_modules/@ant-design/pro-cli step2.install sort-package-json npm i sort-package-json@1.55.0 -D Follow the step,i have solved this problem.

Same error

Update: step1.open ant-design folder cd /usr/local/lib/node_modules/@ant-design/pro-cli step2.install sort-package-json npm i sort-package-json@1.55.0 -D Follow the step,i have solved this problem.

this fixed! THANKS!

For windows:

Open VSCODE

  1. Open folder C:\Users\USERNAME\AppData\Roaming\npm\node_modules\@ant-design\pro-cli
  2. install : npm i sort-package-json@1.55.0 -D
  3. Then freely use anywhere command
pro create my-app-name

Hi guys, I recommend you to take a look here for the installation; https://v5-pro.ant.design/docs/getting-started/

same error