I need to upgrade one of the yarn.lock file from node_modules folder to remove the Raven vulnerabilities issue.
The file path is
src/node_modules/form-data/yarn.lock
I know I can use npm install to install a new package. But is there a way that I can keep the whole package to the current version, but upgrade one file in the package?
You can edit the file directly. Or you can fork the package and update just the file, then publish your fork. But no, there is no way to use
npm(and presumably notyarneither) to update a file without updating the package. That is by design. There are big debugging and malware possibilities if you run annpmcommand and have it report back that you are running version 1.2.3 but in reality you are running version 1.2.3 with one or more files modified.I'm puzzled a bit by your desire to update a
yarn.lockfile in a package.yarn.lockfiles don't affect anything if they're insidenode_modules. This is true both fornpmandyarn. Theyarn.lockfile is ignored if it is not in your top-level project. Updatingyarn.lockinsidenode_moduleswon't do anything to your running code. Perhaps the dependency is listed in your top-levelyarn.lockfile for your project?