作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
"-6ren"> "-我已经生成了一些我想在我的 firebase 函数中使用的代码。 这是我从 github 中提取的私有(private)包,所以在我的 package.json 中我有 "dependencies":-6ren">
我已经生成了一些我想在我的 firebase 函数中使用的代码。
这是我从 github 中提取的私有(private)包,所以在我的 package.json
中我有
"dependencies": {
"@company/package": "1.0.0"
...
}
根据
docs这应该没问题。
$ firebase emulators:start --inspect-functions
i emulators: Starting emulators: auth, functions, firestore, database, storage
⚠ functions: You are running the functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: hosting, pubsub
⚠ Your requested "node" version "14" doesn't match your global version "16"
i firestore: Firestore Emulator logging to firestore-debug.log
i database: Database Emulator logging to database-debug.log
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/home/sfalk/workspaces/web-mobile/functions" for Cloud Functions...
> Debugger listening on ws://localhost:9229/e09c9890-f15b-4634-b9bc-b8528f14c03d
> For help, see: https://nodejs.org/en/docs/inspector
⚠ Error: Cannot find module '@technical-depth/nordigen-client-typescript/api'
Require stack:
- /home/sfalk/workspaces/web-mobile/functions/lib/index.js
- /usr/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/home/sfalk/workspaces/web-mobile/functions/lib/index.js:5:15)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
⚠ We were unable to load your functions code. (see above)
- You may be able to run "npm run build" in your functions directory to resolve this.
运行 build 后,我会在
lib/index.js
中得到生成的输出:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.helloWorld = void 0;
const functions = require("firebase-functions");
const api_1 = require("@company/package/api");
// ...
但错误保持不变。
@company/package
在
node_modules/@company/package
下正确安装依赖项它包含一个
api.ts
包含我需要的代码的文件。
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
}
最佳答案
确保一个文件 node_modules/@company/package/api.js
存在并导出一个 javascript 模块。
关于typescript - 尝试导入自定义包并运行模拟器时获取 "Error: Cannot find module <module>",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69062580/
我是一名优秀的程序员,十分优秀!