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
Cannot find module 'ajv/dist/compile/codegen' #8727
Comments
I'm seeing this issue - we've had to specify 2.17.0 in order for our deploys to work. |
I should add - we don't have a direct dependency on ajv, but we're using other packages that likely have dependencies on ajv. |
@lewgordon Thanks for report, Still this looks to me as issue in your setup, at least provided information shows that: You use globally installed And it appears that local Note that v2.11.1 depends on Line 30 in bde334c
and requires it in lib/class/ConfigSchemaHandler/index.js :
Still what it receives in your case is How did you install |
In our case, serverless is installed as a dev dependency of our project. We are not using ajv directly (though one or more of our dependencies are bringing it in on install). |
As a note, had the same issues starting in
2.17.0 works, 2.18.0 fails with the AJV errors listed above. |
I should note we never leverage a global serverless installation. We rely on |
It'll be great to find out how this broken state happens. At least in @lewgordon it looks as broken installation issue, which is not an issue in Even if service on its own depends on |
I am running into this issue as well. I actually have two projects that use Running
But on the other project, where
I don't understand why there would be an unmet peer dependency in one project and not the other. Neither explicitly includes |
Sorry about that @medikoo ! I agree there was something wrong in my setup. I reproduced the issue I was seeing again, though. I believe there might have been a typo in my original post. Here are the files for the most recent reproduction. Let me know if you need additional information or find anything I've missed. This time I already ran it in the context of a container to isolate the filesystem. I used node with tag
|
Here's another example of probably a more realistic scenario, where there is a dependency on
|
@lewgordon From what I see it's an installation error. How do you install the project ? Is it simply In your output we can see that It looks as a clear bug of installer, as with your configuration, |
Hey @medikoo, it's just a |
@lewgordon I've just tested it locally, and indeed it happens with npm v6, but not with npm v7 which installs project as expected It's a clear bug in npm v6 (it's probably unlikely they'll fix it in that branch) |
npm v7 auto installs peer dependencies, whereas npm v6 does not. It might be this feature that makes it work under npm v7, rather than a bug fix for some behaviour in npm v6? |
Issue is not that peer dependency is not installed, but it's because dependency of |
But it might be that with npm v6 support for peer dependencies was just informative, and in light of that, it's no wonder it cannot handle such setup properly. @lewgordon workaround on your side could be to define |
Seeing as npm v6 is the current LTS version, and npm v7 is the development release, I believe That's assuming I understand the problem correctly. Is there not a way the change to |
@srdone this problem is not specific to latest changes. Same would happen if you'd try to install The only "complete fix" could be to not use in I believe right approach is to acknowledge the specificity of a setup and find a way to install it properly (either use package manager that handles peer dependencies, or workaround it as I proposed above) |
I was facing the same issue with, I temporarily solved it by installing
It's just a "workaround" for those who need to deploy their applications, and problably will be fixed asap. By the way I'm running the |
@medikoo - we are currently getting around this issue by pinning our dev dependency on serverless at v.2.17.0, so the problem does not exist there. Note that we do not have any direct dependency on ajv - but rather another package we are using has it as a dependency. |
I think there is something funny about version My projects don't have a direct dependency on |
I believe some other dependency in your setup relies on Note that this issue will happen if two dependencies rely on different version of We may downgrade back |
In the project where upgrading to version
As I say, this one works and does not run into the error |
In our project, before upgrading to
After upgrading to
This suggests to me that serverless expects
The user is then expected to install the missing peer dependency in their project where the package requiring the peer dependency is used. I can, of course, install |
@srdone Line 29 in 2b7568a
If in your case installed |
Just to chime in... this odd issue also threw our CI/CD build pipeline for a loop. Clearly, whether this is "intended behavior" or not, this change to the |
I believe it caused issues to cases where (1) service depends directly on Note that all we did is upgrading |
I think @medikoo is correct that this issue has been caused by This looks to be an example of a bug in npm that's been around for a long time. That issue is almost 2 years old and was never resolved by the look of things. It might have been resolved by npm version 7, but I can't find confirmation of that anywhere. The person who raised that issue did a great job of reproducing the problem, and you can see that the circumstances in their demo project are very similar to the case that we're seeing here. Just replace In which case, I suppose the options are to do one of the following:
|
See serverless/serverless#8712 for details of the security vulnerability. This update to Serverless has necessitated us installing "ajv" as a dev dependency. "ajv" is a peer dependency of one of Serverless' dependencies, and shouldn't normally require us to install it (because Serverless itself does), however there is a long-standing bug in npm that leads to npm being unable to resolve peer dependencies in certain circumstances, this being one of them. More details at serverless/serverless#8727 and npm/npm#19877
AJV will be reverted to v6 starting with next release of Framework, it's due to performance issues with observed which appear to not be easily fixable, for more info check:
This means that this problem will be fixed for you, unless you've upgraded your services to rely on AJV v7, as then you'll face the same problem with same installer when |
This seems fixed as far as I can tell, I think we can close it? |
Not sure if this is something that just can't be helped, but it seems that if a NodeJS project has a dependency on
ajv^6
it'll cause the packaging step to fail. I believe this was caused by the bump toajv^7
. I know that many projects still depend on the earlier version, so it might break a lot of projects.Steps to reproduce:
sls init
ajv^6
vianpm i ajv@^6
sls package
serverless.yml
sls package
outputInstalled version
The text was updated successfully, but these errors were encountered: