Boe*_*ern 8 npm firebase google-cloud-functions yarnpkg
我有一个具有以下文件结构的 monorepo 设置:
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 functions\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 shared\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dist\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 frontend\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 firebase.json\nRun Code Online (Sandbox Code Playgroud)\n./shared持有在./backend和之间共享的 TypeScript 类./frontend。理想情况下,我想使用functions/package.json符号链接引用共享库,以避免每次更改共享代码(大部分功能都位于其中)后都必须重新安装。
但是,这不起作用(既不使用link:,也不使用绝对file:路径,也不使用相对file:路径)
// functions/package.json\n ...\n "dependencies": {\n "shared": "file:/home/boern/Desktop/wd/monorepo/shared"\n ...\n }\nRun Code Online (Sandbox Code Playgroud)\n导致错误firebase deploy --only functions( error Package "shared" refers to a non-existing file \'"home/boern/Desktop/wd/monorepo/shared"\')。库(尽管存在于 中./functions/node_modules/)未传输到服务器?
此外,"functions": {"ignore": []}firebase.json 中的设置也没有帮助。
唯一有效的是adevine 在 Github 上的提案:
\n// functions/package.json\n ...\n "scripts": {\n ...\n "preinstall": "if [ -d ../shared ]; then npm pack ../shared; fi"\n },\n "dependencies": {\n "shared": "file:./bbshared-1.0.0.tgz"\n ...\n }\nRun Code Online (Sandbox Code Playgroud)\n有人可以指出一种引用本地库的方法吗?a)./functions在开发过程中始终使用最新版本,b)使用库存 Firebase CLI 成功部署(而不是,例如使用firelink)?或者这根本不支持?
这是我使方法 4 发挥作用的解决方法:
rm -rf ./node_modules
yarn cache clean # THIS IS IMPORTANT
yarn install
Run Code Online (Sandbox Code Playgroud)
./functions从文件夹运行它
| 归档时间: |
|
| 查看次数: |
1445 次 |
| 最近记录: |