gpt4 book ai didi

node.js - Google Datastore 仍然指向 App Engine 生产数据库而不是本地模拟器

转载 作者:太空宇宙 更新时间:2023-11-03 22:25:39 25 4
gpt4 key购买 nike

我有一个正在本地构建的本地 NodeJS 应用程序。

我希望本地应用程序指向本地数据存储模拟器(而不是生产云数据存储)。

我按照本页上的说明进行操作...但是,应用程序仍然指向 CLOUD 数据存储(不是我的本地数据存储)。我确认了这一点,因为数据显示在 App Engine 上的“数据存储实体”页面中。

根据此页面,https://cloud.google.com/datastore/docs/tools/datastore-emulator所需要的只是通过运行以下命令来设置环境变量:

$(gcloud beta emulators datastore env-init)

我确认环境变量设置正确。为什么我的应用程序仍然指向云数据存储而不是本地模拟器?

myusername$ $(gcloud beta emulators datastore env-init)
myusername$ gcloud beta emulators datastore env-init
export DATASTORE_DATASET=projectname
export DATASTORE_EMULATOR_HOST=localhost:8081
export DATASTORE_EMULATOR_HOST_PATH=localhost:8081/datastore
export DATASTORE_HOST=http://localhost:8081
export DATASTORE_PROJECT_ID=projectname

这是运行模拟器时的输出:

myname$ gcloud beta emulators datastore start
WARNING: Reusing existing data in [/Users/myname/.config/gcloud/emulators/datastore].
Executing: /Users/myname/google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator start --host=localhost --port=8081 --store_on_disk=True --consistency=0.9 --allow_remote_shutdown /Users/myname/.config/gcloud/emulators/datastore
[datastore] Oct 30, 2017 3:47:46 PM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$8 apply
[datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary.
[datastore] Oct 30, 2017 3:47:46 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub <init>
[datastore] INFO: Local Datastore initialized:
[datastore] Type: High Replication
[datastore] Storage: /Users/myname/.config/gcloud/emulators/datastore/WEB-INF/appengine-generated/local_db.bin
[datastore] Oct 30, 2017 3:47:47 PM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub load
[datastore] INFO: The backing store, /Users/myname/.config/gcloud/emulators/datastore/WEB-INF/appengine-generated/local_db.bin, does not exist. It will be created.
[datastore] Oct 30, 2017 3:47:47 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
[datastore] INFO: Unable to apply Java 7 long hostname workaround.
[datastore] API endpoint: http://localhost:8081
[datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run:
[datastore]
[datastore] export DATASTORE_EMULATOR_HOST=localhost:8081
[datastore]
[datastore] Dev App Server is now running.
[datastore]

最佳答案

我发现设置 DATASTORE_EMULATOR_HOSTDATASTORE_PROJECT_ID 就足够了。

也许它正在寻找指向云的其他环境变量?

您是否尝试过清除 GOOGLE_APPLICATION_CREDENTIALS 环境变量?

关于node.js - Google Datastore 仍然指向 App Engine 生产数据库而不是本地模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47023329/

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