gpt4 book ai didi

node.js - 在新的 react 项目中使用 craco - 什么会导致这个错误? (未处理的PromiseRejectionWarning : TypeError [ERR_INVALID_ARG_VALUE]: . ..)

转载 作者:行者123 更新时间:2023-12-04 12:15:48 24 4
gpt4 key购买 nike

概括
在创建一个新项目并尝试使用 craco 时,我遇到了一个我不明白的错误。
我有什么
错误看起来像这样......

$ craco start
(node:125281) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received ''
at Module.require (internal/modules/cjs/loader.js:1084:11)
at require (internal/modules/cjs/helpers.js:73:18)
at getConfigAsObject (/home/glaucon/src/20210416testB/my-app/node_modules/@craco/craco/lib/config.js:46:20)
at loadCracoConfigAsync (/home/glaucon/src/20210416testB/my-app/node_modules/@craco/craco/lib/config.js:69:34)
at Object.<anonymous> (/home/glaucon/src/20210416testB/my-app/node_modules/@craco/craco/scripts/start.js:22:1)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:125281) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:125281) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 1.06s.


我所做的
为了达到这一点,我所做的是......
$ yarn global remove create-react-app
$ mkdir 20210416testB
$ cd 20210416testB
$ npx create-react-app my-app
$ cd my-app/
$ yarn add @craco/craco
将 package.json 修改为 follows ...
"scripts": {
- "start": "react-scripts start",
+ "start": "craco start",
- "build": "react-scripts build",
+ "build": "craco build"
- "test": "react-scripts test",
+ "test": "craco test"
}
然后完成
$ yarn start
在这一点上我得到了上面的错误所以我
$ rm -rf ./node_modules/
$ yarn install
$ yarn start
但我仍然收到上面的错误。
将不胜感激任何建议。

最佳答案

请确保 craco.config.js文件在您的根目录中 :)

关于node.js - 在新的 react 项目中使用 craco - 什么会导致这个错误? (未处理的PromiseRejectionWarning : TypeError [ERR_INVALID_ARG_VALUE]: . ..),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67116773/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com