我正在关注阿尔戈利亚文件。
https://www.algolia.com/doc/tutorials/indexing/3rd-party-service/firebase-algolia/
我做了文档告诉我的所有步骤,但这给了我错误。
internal/modules/cjs/loader.js:589
throw err;
^
Error: Cannot find module 'firebase'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
at Function.Module._load (internal/modules/cjs/loader.js:513:25)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/home/ali/Desktop/algolia/index.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
如何解决?
这是我尝试使用npm安装firebase模块时得到的。
错误:
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.16.0/node-v67-linux-x64-glibc.tar.gz
node-pre-gyp WARN Pre-built binaries not found for grpc@1.16.0 and node@11.1.0 (node-v67 ABI, glibc) (falling back to source compile with node-gyp)
gyp ERR! build error
gyp ERR! stack Error: not found: make
gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/node-gyp/node_modules/which/which.js:13:12)
gyp ERR! stack at F (/usr/lib/node_modules/node-gyp/node_modules/which/which.js:68:19)
gyp ERR! stack at E (/usr/lib/node_modules/node-gyp/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/lib/node_modules/node-gyp/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/lib/node_modules/node-gyp/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/lib/node_modules/node-gyp/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:161:21)
gyp ERR! System Linux 4.19.2-1-MANJARO
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /home/ali/Desktop/algolia/node_modules/grpc
gyp ERR! node -v v11.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/ali/Desktop/algolia/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)
node-pre-gyp ERR! System Linux 4.19.2-1-MANJARO
node-pre-gyp ERR! command "/usr/bin/node" "/home/ali/Desktop/algolia/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /home/ali/Desktop/algolia/node_modules/grpc
node-pre-gyp ERR! node -v v11.1.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/ali/Desktop/algolia/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc --napi_version=3 --node_abi_napi=napi' (1)
npm WARN algolia@1.0.0 No description
npm WARN algolia@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.16.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.16.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ali/.npm/_logs/2018-11-23T17_32_22_514Z-debug.log
答案 0 :(得分:0)
尝试使用命令npm-install firebase。 它将附带消息firebase安装版本。 之后,转到package.Json的依赖项下,添加“ firebase”:“版本号”。这样可以解决您的问题。