- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个名为 shared
的子模块,它位于 backend
文件夹(即云函数文件夹)旁边:
我在 backend/package.json
中添加了本地依赖 shared
,如下所示:
"dependencies": {
...
"shared": "file:../shared"
}
我运行了 npm install
并确保 node_modules/shared
存在。虽然,当我运行以下代码时:
firebase deploy --only functions
我收到以下错误(来自 firebase):
Error: Error parsing triggers: Cannot find module 'shared/common'
Try running "npm install" in your functions directory before deploying.
这个错误是由于这一行:
import { currentWeek } from 'shared/common';
如果我将目录更改为 ../../../shared/common
,firebase 将编译而不会出现任何错误。
export { currentWeek } from './current-week';
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"module": "commonjs",
"declaration": true,
"strict": true,
"removeComments": true
}
}
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"outDir": "./dist",
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"target": "es6",
"moduleResolution": "node",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2015",
"dom"
]
},
"include": [
"./src/**/*",
"../shared/**/*"
]
}
如果我有这个模块,为什么会出现这个错误?有什么我想念的吗?
最佳答案
我认为,您必须为 typescript 编译器配置 module-resolution
。
针对您的情况:
{
"compilerOptions": {
"baseUrl": ".", // This must be specified if "paths" is.
"paths": {
"shared/*": ["../shared/*"] // This mapping is relative to "baseUrl".
}
}
}
你可以用另一个名字命名shared
。
{
"compilerOptions": {
"baseUrl": ".", // This must be specified if "paths" is.
"paths": {
"myLib/*": ["../shared/*"] // This mapping is relative to "baseUrl".
}
}
}
用法:
import { currentWeek } from "myLib/common";
关于typescript - Firebase 部署 - 找不到本地依赖项的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54816967/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!