【发布时间】:2020-04-25 17:10:22
【问题描述】:
这是我尝试创建 React 应用程序时运行的命令以及生成的错误日志。我之前使用命令$ npx create-react-app 已经能够成功运行它三次,但是现在每次运行它时,它都不起作用,而是返回与 ES 模块相关的错误。我一直在尝试将 React 与 Django 集成的多种方法,但我认为我没有编辑任何会导致此错误的核心文件。我对 React 和 Node.js 完全陌生,因此非常感谢任何建议。
npx: installed 99 in 7.591s
Must use import to load ES Module: /Users/(username)/.npm/_npx/27993/lib/node_modules/create-react-app/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /Users/(username)/.npm/_npx/27993/lib/node_modules/create-react-app/node_modules/is-promise/index.js from /Users/(username)/.npm/_npx/27993/lib/node_modules/create-react-app/node_modules/run-async/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /Users/(username)/.npm/_npx/27993/lib/node_modules/create-react-app/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/(username)/.npm/_npx/27993/lib/node_modules/create-react-app/node_modules/is-promise/package.json.```
【问题讨论】:
标签: node.js django reactjs npm npx