gpt4 book ai didi

javascript - env-cmd 错误无法在 gatsby 中找到 ./.env 文件?

转载 作者:搜寻专家 更新时间:2023-10-31 22:55:35 24 4
gpt4 key购买 nike

我在根文件夹中有一个名为 .env.development 的文件。我安装了 env-cmd 作为开发依赖
当我启动服务器时

  > npm run develop

它给我一个错误

> gatsby-starter-hello-world@0.1.0 develop I:\learngatsby
> env-cmd .env-development gatsby develop

(node:1368) UnhandledPromiseRejectionWarning: Error: Unable to locate env file at default location (./.env)
at I:\learngatsby\node_modules\env-cmd\dist\get-env-vars.js:44:19
at Generator.throw (<anonymous>)
at rejected (I:\learngatsby\node_modules\env-cmd\dist\get-env-vars.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
(node:1368) 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(). (rejection id: 2)
(node:1368) [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.

最佳答案

您可以使用带有 -f 标志的自定义 .env 文件和 env-cmd 来设置环境变量。使用此命令设置自定义文件 './config/myvar.env' 中定义的 env 变量。

env-cmd -f ./config/myvar.env

有关更多信息,请使用此 link

关于javascript - env-cmd 错误无法在 gatsby 中找到 ./.env 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56301852/

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