-
Notifications
You must be signed in to change notification settings - Fork 13
add workaround for npm workspaces #63
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
Comments
Issue: CS-189 |
Hello @vrohatgi! -- snyk does not support NPM workspaces directly, and so it was also not considered for use case in snyk-bulk, however I believe its similar to yarn workspaces, and we used a trick to add support for it, as shown here The idea here was that we had one Because snyk uses the package.json as a manifest (it will only include in the dependency tree what is being brought in through the direct dependencies in the package.son) while also using the lock file to ensure accuracy of the transitives and versions, this happens to work well. Do you see the same approach will be viable here? If so it will be trivial to add support as its almost identical to the yarn workspace support, however we're not very familiar with it so sanity checking this approach will be helpful. |
I did a little testing with npm workspaces and I think I found a trick works. Not all workspace directories will have a If you make an empty So to get it to work, I think all you'd need to do is run The package-lock.json trick doesn't seem to work. If one of the workspaces has a vulnerable dependency and I link the root packag-lock.json in the subfolder, Snyk doesn't find the vulnerable dependency. |
Hi @chris-walz 👋 ! -- thats too bad it doesn't work like the |
Thanks @scott-es ! Good point about the npm versions. I was testing on 9. I would think that it would work the same on any version that supports workspaces, but haven't tested that. |
Hey @scott-es, any updates on the testing? |
snyk -v
: 1.1052.0snyk test
Expected behaviour
snyk-bulk should be able to recursively scan npm workspaces.
Actual behaviour
npm workspaces do not have their own package-lock.json file; instead, a single lock file in the root of the project is used for all workspaces in the project. snyk-bulk does not support this project layout and fails when trying to recursively scan each workspace.
If applicable, please append the
--debug
flag on your command and include the output here **ensuring to remove any sensitive/personal details or tokens.The text was updated successfully, but these errors were encountered: