-
Notifications
You must be signed in to change notification settings - Fork 417
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
Unable to deploy a service using local packages #370
Comments
I ran into this exact same problem today. My yarn.lock file is up-to-date but the build still reports that it isn't. The command that fails in the build process runs without issue when executed manually. |
Hi @nickelstar , Can you check the The |
Thanks for the helpful info. When I looked at .webpack/dependencies/package.json, I noticed a package listed with an empty version number:
This struck me as odd since I don't use aws-sdk and it's not listed in my package.json. So I added it to my package.json via 'yarn add aws-sdk'. After that, the error went away and deployments started working with yarn specified as the webpack packager. |
@nickelstar Good to hear that. I think you can even move the aws-sdk to |
@HyperBrain "dependencies": {
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"mongodb": "^2.2.33",
"mssql": "^4.1.0",
"object.values": "^1.0.4",
"papaparse": "^4.3.6",
"slug": "^0.9.1",
"source-map-support": "^0.5.0",
"sprintf-js": "^1.1.1",
"underscore": "^1.8.3"
},
"devDependencies": {
"aws-sdk": "^2.172.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-jest": "^22.1.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"eslint": "^4.16.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-flowtype": "^2.40.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.7.0",
"flow-bin": "^0.63.1",
"flow-typed": "^2.4.0",
"glob": "^7.1.2",
"jest": "^22.2.0",
"serverless": "^1.25.0",
"serverless-log-forwarding": "^1.1.6",
"serverless-offline": "^3.16.0",
"serverless-secrets": "https://github.com/franciscocpg/serverless-secrets.git#e623994662366b6fcfe7cc40f1d85fd19b5029cd",
"serverless-webpack": "^5.1.1",
"webpack": "^3.10.0",
"webpack-node-externals": "^1.6.0",
"webpack-plugin-copy": "^1.0.1"
} and then I see this {
(...)
"dependencies": {
"mongodb": "^2.2.33",
"mssql": "^4.1.0",
"object.values": "^1.0.4",
"source-map-support": "^0.5.0",
"moment": "^2.20.1",
"lodash": "",
"slug": "^0.9.1",
"moment-timezone": "^0.5.14",
"papaparse": "^4.3.6",
"underscore": "^1.8.3",
"sprintf-js": "^1.1.1"
}
} This empty lodash ( If I remove it Also when I run |
@franciscocpg That is strange. The lodash in the package.json points out that webpack deteceted it as a primary dependency of your code, but it seems to be missing in your original package.json. This can happen if you use it directly in your code (by using import or require lodash) but forgot to add it as dependency. If any of your dependencies brings lodash in, you won't recognize the error locally, because it is implicitly in the node_modules folder. NPM might swallow such issues, but yarn - with it's better optimization - will bring it to the surface. |
@HyperBrain |
@franciscocpg Yes, you're right. This looks like a bug in the Yarn dependency tree transform ( |
Just struck this too (the original issue with local packages, not the lodash problem). My local package is called
But in
So the relative link in |
@damonmaria Yes, that's exactly the problem. For In theory the same approach as with npm should work (that's an easy one). I'll prepare a PR soon and handle this with high prio so that you can try and test that later. |
I'm working on a solution right now. However, there are 2 cases how local files can be integrated with yarn, so both need a proper handling: case 1: I'll do a first try to rebase any version reference that is file-like. If we encounter issues with that, we could - at least for now - restrict file references to use only the |
@franciscocpg I think we should separate the 2 issues contained in this one into 2 issues. I will fix the "local file references not handled" here and close it with the PR, but I think thet the dependency issue with yarn and transient dependencies is important too and should be solved and discussed properly. |
@HyperBrain I'm going to be out on the next 2 weeks so I'm unable to help during this period. About the |
@franciscocpg Agree & no problem 😄 . Just tested the attached PR #376 and for me it worked now locally with yarn + file references. I'll add some unit tests, but anyone here (@damonmaria , @mzmiric5 ) can already test if it solves the problem. |
I actually worked around this. My use case was sharing a project package across the different parts of the project. Once I struck this (and similar issues with the same shared package in non-Serverless parts of the project ) I instead installed the package (again as a |
@HyperBrain just tested the PR branch with our private package and this fixed the issue we were having. Thanks a lot for a quick fix. |
Released with 5.1.3 |
I'm experiencing this issue using serverless-webpack 5.2.0. I have private scoped packages, and one of the dependencies that are defined in my private package is showing up without a version in
|
I am using |
I found that somehow that my dependency on |
I'd appreciate some advice on this issue to see if it's been resolved. I've been trying to deploy a serverless application that uses a local private package managed by Yarn Workspaces with no success, despite repeated different attempts I still get stuck with:
(Even though things build outside of building with I'm now about to try a different approach and publish the private package to a private npm repository, but before I start that I'm researching whether this is likely to suceed. We are using Yarn as our package manager, so would definitely prefer to continue, but I would love to know if that is likely to succeed, and if switching to npm would make it more likely? Thanks in advance. |
@danrivett, I was able to get serverless-webpack working in yarn monorepos by whitelisting them like so in the webpack config file..
|
This worked perfectly for me, except the parameter name is different:
Thank you for showing me the way... |
This is a Bug Report
Description
When attempting to package or deploy a service which uses local packages either referenced via
file:
or yarn-workspace definitions, the deploy/package step that triggers the webpack build throws an error withRunning
yarn install --frozen-lockfile --non-interactive
manually works just fine, so that points to an issue withserverless-webpack
.For bug reports:
sls deploy
andsls package
fail with"Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`."
error when using a local packageThe service should have been packaged and deployed successfully
@HyperBrain as requested in #369 I've opened a separate issue. I also went ahead and prepared a minimal repro repo with the config and dependencies set up that cause these issues to surface. https://github.com/mzmiric5/sls-wp-build-error-repro
Some notes:
For feature proposals:
Similar or dependent issue(s):
Additional Data
The text was updated successfully, but these errors were encountered: