Uze*_*zer 0 firebase typescript google-cloud-functions
嗨,我有一个问题,当该项目包含另一个打字稿依赖时,通过firebase-tools将我的typescript express应用程序部署到firebase.在谷歌功能中运行时,构建过程可能出现问题.请注意,程序在本地按预期工作,这只是部署的问题.
这是MVE的回购:
https://github.com/jk89/baseRepo
这加载了两个依赖:
https://github.com/jk89/depRepo1
https://github.com/jk89/depRepo2
我从firebase-tools'firebase deploy'得到以下错误:
jty@carrot:~/April2018/typescript-min-ver/baseRepo$ firebase deploy
=== Deploying to 'pricecalculator-e88d6'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build
> base-repo@0.1.0 build /home/jty/April2018/typescript-min-ver/baseRepo
> npm run tslint && tsc --declaration
> base-repo@0.1.0 tslint /home/jty/April2018/typescript-min-ver/baseRepo
> tslint -c tslint.json -p tsconfig.json
? functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
? functions: all necessary APIs are enabled
i functions: preparing . directory for uploading...
i functions: packaged . (12.76 KB) for uploading
? functions: . folder uploaded successfully
i functions: updating Node.js 8 function webApi(us-central1)...
? functions[webApi(us-central1)]: Deployment error.
Function load error: Code in file ./lib/index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'dep-repo-1'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/lib/index.js:7:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Having trouble? Try firebase deploy --help
Run Code Online (Sandbox Code Playgroud)
当然,这是使用模块化打字稿模块的常见用例.我不明白为什么它不起作用?!
当Firebase尝试安装和构建您的函数时,它会查看dep-repo-1/package.json中的字段 "module": "./dist/index.js"
并尝试按照它进行操作.由于该文件不存在,因此抛出Error: Cannot find module 'dep-repo-1'
该文件不存在,因为在每个子模块中,dist
目录未发布到Github,并且Firebase不会自动构建您的npm包.(dist/
包括在内.gitignore
)
有关如何构建模块的一些选项:
dist/
和忽略lib/
).这类似于如何npm publish
设置使用的模块.dist/
在存储库中包含该目录即可.这不太干净(因为您在应该是仅源的存储库中包含构建的文件)"install": "tsc"
在每个模块的package.json中创建一个脚本.这将在你进行npm安装时运行.确保将typescript添加到依赖项列表中,因为Firebase构建环境没有预先安装它. 归档时间: |
|
查看次数: |
192 次 |
最近记录: |