我有一个名为 End_Time
1/18/2019 9:15 #<-- Based on Sue's start time - 1 min
2/1/2019 12:25 #<-- Based on Mary's start time - 1 min
2/1/2019 14:03 #<-- Based on Joe's start time - 1 min
today() #<-- Joe still has it
today() #<-- Jerry still has it
1/17/2019 19:57 #<-- Based on Tim's start time - 1 min
today() #<-- Tim still has it
today() #<-- Tim has this unique device.
的子模块,它位于shared
文件夹(这是云功能文件夹)的旁边:
我在backend
中添加了本地依赖项shared
,如下所示:
backend/package.json
我运行了"dependencies": {
...
"shared": "file:../shared"
}
,并确保npm install
存在。虽然,当我运行以下代码时:
node_modules/shared
我收到以下错误(通过firebase):
firebase deploy --only functions
此错误是由于以下原因引起的:
Error: Error parsing triggers: Cannot find module 'shared/common'
Try running "npm install" in your functions directory before deploying.
如果我将目录更改为import { currentWeek } from 'shared/common';
,firebase将会编译而不会出现任何错误。
../../../shared/common
export { currentWeek } from './current-week';
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"module": "commonjs",
"declaration": true,
"strict": true,
"removeComments": true
}
}
如果我有此模块,为什么会出现此错误?有什么我想念的吗?
答案 0 :(得分:0)
我认为,您必须为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";