Open cbumstead opened 5 years ago
@cbumstead - Seems like I'm having a similar issue. After the plugin gets installed as per my codebuild buildspec. Why the plugin cannot find ./aws-lambda/package.json
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
commands:
- yarn global add serverless
build:
commands:
- cd packages/personalization-logic
- serverless plugin install -n serverless-plugin-typescript
- serverless plugin install -n serverless-plugin-aws-resolvers
- serverless plugin install -n serverless-offline-sqs
- serverless plugin install -n serverless-offline
- serverless plugin install -n serverless-plugin-scripts
- serverless plugin install -n serverless-plugin-monorepo
post_build:
commands:
- cd packages/personalization-logic
- serverless deploy --stage=${STAGE} --verbose
I get this error which aligns with your note above where symbolic links are removed:
Serverless: Successfully installed "serverless-plugin-monorepo@latest"
--
169 |
170 | [Container] 2021/08/22 20:12:15 Phase complete: BUILD State: SUCCEEDED
171 | [Container] 2021/08/22 20:12:15 Phase context status code: Message:
172 | [Container] 2021/08/22 20:12:16 Entering phase POST_BUILD
173 | [Container] 2021/08/22 20:12:16 Running command serverless deploy --stage=${STAGE} --verbose
174 | Serverless: Running "serverless" installed locally (in service node_modules)
175 | Serverless: Cleaning dependency symlinks
176 | Serverless: Creating dependency symlinks
177 |
178 | Error --------------------------------------------------
179 |
180 | Error: Cannot find module './aws-lambda/package.json'
181 | Require stack:
182 | - /codebuild/output/src290709275/src/github.com/Acornsgrow/found-money-personalization/packages/personalization-logic/node_modules/serverless-plugin-monorepo/lib/index.js
It looks like Butterwire is no more, so someone motivated will have to fork the repo to fix any issues.
This plugin looks for to the node_modules to know where to find the packages to link but that's a different approach than
yarn workspaces
takes.yarn workspaces
uses the workspaces array in the package.json to know where to look for the packages to link. That allows it to know where the packages can be found even if node_modules doesn't have any of the packages. It seems like that would be a good approach for the serverless-plugin-monorepo as well.What is happening for me is that I am running
yarn install
at the root of the project and some of my packages are hoisted and symlinked at that time and are in the top level node_modules folder. Then when runningserverless deploy
the symlinks are cleaned and removed and when the plugin tries to recreate the links it looks to the node_modules for the packages but there's nothing there because it just cleaned up the links. My workaround was to comment out the clean functions references from the plugin and runyarn install
before runningserverless deploy
.