【发布时间】:2019-05-25 05:00:09
【问题描述】:
我在根文件夹中有一个文件名 .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.
【问题讨论】:
-
可能仅在名称为
.env而不是.env-development或.env.development时才有效 -
不,它没有工作
-
为什么错误中有
.env-development,但根目录下的文件名是.env.development? -
我认为您在控制台“env-cmd .env-development gatsby develop”中使用了这一行,这不是错误。这只是控制台视图。错误语句从第四行开始
-
如果你的文件名是
env.development,命令不应该是env-cmd .env.development gatsby develop而不是env-cmd .env-development gatsby develop
标签: javascript node.js