【发布时间】:2020-09-07 11:51:15
【问题描述】:
我正在尝试使用 Nuxt 使用 Firestore 数据库。但是下面的代码在编译时会产生错误。 我留下了我正在做的项目的一些摘录
在这个文件中我已经配置了数据库凭据路径
README.md
$env:GOOGLE_APPLICATION_CREDENTIALS="D:\Educacion\Proyectos\Go\social\whatsapp-f91a0.json"
nuxt.config.js
plugins: [
'@plugins/firebase.js'
],
插件
firebase.js
var admin = require("firebase-admin");
var serviceAccount = require("whatsapp-f91a0.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://whatsapp-f91a0.firebaseio.com"
});
const db = admin.database();
export {db}
index.vue
<script>
import db from 'firebase';
db.collection('categorias').doc('aaa').get()
.then(doc=>{
if (!doc.exists){
console.log('no existe')
}
})
.catch(err=>{
console.error('error', err);
process.exit();
});
</script>
这里编译的时候报错
错误
WARN Compiled with 3 warnings friendly-errors 17:54:45
WARN in ./node_modules/hash-stream-validation/index.js friendly-errors 17:54:45
Module not found: Error: Can't resolve 'fast-crc32c' in 'D:\Educacion\Proyectos\Go\social\node_modules\hash-stream-validation' friendly-errors 17:54:45
friendly-errors 17:54:45
WARN in ./node_modules/retry-request/index.js friendly-errors 17:54:45
Module not found: Error: Can't resolve 'request' in 'D:\Educacion\Proyectos\Go\social\node_modules\retry-request' friendly-errors 17:54:45
friendly-errors 17:54:45
WARN in ./node_modules/configstore/node_modules/write-file-atomic/index.js friendly-errors 17:54:45
Module not found: Error: Can't resolve 'worker_threads' in 'D:\Educacion\Proyectos\Go\social\node_modules\configstore\node_modules\write-file-atomic'
friendly-errors 17:54:45
ERROR Failed to compile with 20 errors friendly-errors 17:54:45
These dependencies were not found: friendly-errors 17:54:45
friendly-errors 17:54:45
* child_process in ./node_modules/google-auth-library/build/src/auth/googleauth.js friendly-errors 17:54:45
* dns in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js friendly-errors 17:54:45
WARN in ./node_modules/configstore/node_modules/write-file-atomic/index.js friendly-errors 17:54:45
Module not found: Error: Can't resolve 'worker_threads' in 'D:\Educacion\Proyectos\Go\social\node_modules\configstore\node_modules\write-file-atomic'
friendly-errors 17:54:45
ERROR Failed to compile with 20 errors friendly-errors 17:54:45
These dependencies were not found: friendly-errors 17:54:45
friendly-errors 17:54:45
* child_process in ./node_modules/google-auth-library/build/src/auth/googleauth.js friendly-errors 17:54:45
* dns in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js friendly-errors 17:54:45
* fs in ./node_modules/@google-cloud/storage/build/src/file.js, ./node_modules/@grpc/grpc-js/build/src/tls-helpers.js and 8 others friendly-errors 17:54:45
* http2 in ./node_modules/@grpc/grpc-js/build/src/server.js friendly-errors 17:54:45
* net in ./node_modules/@grpc/grpc-js/build/src/resolver-dns.js, ./node_modules/http-proxy-agent/dist/agent.js and 1 other friendly-errors 17:54:45
* tls in ./node_modules/@grpc/grpc-js/build/src/channel-credentials.js, ./node_modules/http-proxy-agent/dist/agent.js and 1 other friendly-errors 17:54:46
* whatsapp-f91a0.json in ./plugins/firebase.js
有人可以帮我吗
【问题讨论】:
-
该错误表明您的项目中没有安装一些依赖项,例如
googleauth.js和resolver-dns.js等。您是否尝试过在构建期间重新安装依赖项? -
@ralemos 您好,我已经安装了依赖项,但仍然出现错误。虽然在 firebase 页面上并没有提到它需要额外的依赖项
标签: javascript node.js firebase google-cloud-firestore nuxt.js