New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于将 egg 项目 node_modules 上传层部署问题 #11
Labels
Comments
该方法我这里测试不行,报这个错误,将 node_modules 上传后没问题
|
@iqingting 如果使用的是 v1 版本,可以尝试清理本地缓存 |
v2 版本,重新部署还是这个问题。是不是因为 |
同时确保上传的 layer 是包含 |
搞定了。之前是直接上传的文件夹,所以有问题。自己压缩上传 zip 包就可以了 |
已支持基于层部署自动注入配置变更:#20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
由于
egg
框架在加载插件时,查询路径是固定的三个路径:{APP_PATH}/node_modules
{EGG_PATH}/node_modules
$CWD/node_modules
官方代码:
参考:https://github.com/eggjs/egg-core/blob/ca04a457c8cc7a1c1cc77a4e62a6cfde29a5ef19/lib/loader/mixin/plugin.js#L328-L359
导致如果将
node_modules
部署到层后,egg
的云函数会报插件找不到问题,主要是EGG_PATH
路径在层加载的目录下面,此路径会变成/opt/egg
,进而导致查询 egg 插件模块路径变成/opt/egg/node_modules
,而此时所有 npm 依赖模块路径是/opt/node_modules
,为此我们需要改写EGG_PATH
,代码如下:最终解决方案,在项目目录新增
sls.js
入口文件:然后重新部署即可。
The text was updated successfully, but these errors were encountered: