Is it possible to disable dependency resolution in YARN while yarn upgrade - npm

I have a custom dependency (my own package that is in the same monorepo and was installed with yarn add <path-to-folder>). When I amend my custom package, build it and then perform yarn upgrade <my-custom-package-name> I always need to wait until yarn resolves all the dependencies. I need to optimize the time that I need to wait until yarn upgrade will finish.
Is it possible to somehow disable that dependency resolution when updating that package so that it will be faster?
If not possible with Yarn, is it possible with NPM?

Related

how do i add yarn package to react native project installed with npm?

Note: Do guide me if something is missing.
So, I wanted to install a package from https://rnfirebase.io/auth/usage, but I have an npm project. The command on the website has only for yarn. I don't want to add yarn to project because (Is there any harm in using NPM and Yarn in the same project?) it states that it is not recommended.
So, then how do I install it with npm?
You have to use yarn, or you can look for a package that has the functions that you are looking for using npm
You can install it with npm just fine, don't worry. They are all package managers installing npm packages from the same repository. There is no difference in what you are installing or how they are installed. You can get different node_module structures, but for yarn you need config for that.
Yes its not recommended because it generates different lockfiles that will dictate different structures and versions in your node_modules folder. You want multiples devs to have the same "experience". However, lots of JS frameworks will come pre-configured with yarn, like React Native and you just end up having two lockfiles. One for npm and one for yarn. There is no harm in deleting the yarn file and keeping the package-lock. If you delete both, a new lockfile for the package manager you are using will be generated on npm i | yarn i | pnpm anyway.
To install it with npm just use npm i <PACKAGE_NAME> so npm i #react-native-firebase/app.
Here is the npm repo page for that package, https://www.npmjs.com/package/#react-native-firebase/app, notice the install command is npm! Only reason firebase devs only mention yarn is because they are hipsters ;)

npm start install my package, but i'm running my project with yarn start

If I installed some package with NPM it will work and recognize it if I run my project with yarn start instead npm start?
Yes, it will still work after all the required packages are installed.
But you should not switch package Managers like that since you will generate two lock files if you use both to install packages. npm generates the package-lock.json and yarn will generate the yarn.lock file. I recommend you to stay with one or switch completely.
In runtime, it does not make any difference if you use yarn or npm.
npm run start and yarn start will do exactly the same.

Upgrade/update a node package in package.json without installing it?

This question applies to either npm or yarn and I would like to know if what I need to do can be done with one or the other or both. For the sake of clarity I will only refer to yarn commands as I would prefer the yarn solution.
I have a bash script where I conditionally yarn upgrade a node package that is guaranteed to be in the package.json file but has not yet been installed. I would like to potentially reduce the number of times I call yarn install. As it stands I need to call yarn install and then yarn upgrade but I don't need to because I will be calling yarn install later in the script.
I think I can save a call to yarn install (via a yarn upgrade) in my script by simply updating the version number for the node package I want upgraded in package.json but then do not actually install any of those files since I will be calling yarn install at a later time in the script.
I would simply like to change the version number of a specific node package without installing any files using either a yarn or npm command. If this is not possible is this a good use case to parse package.json by hand and insert the version number with brute force?
Dependencies can be added to your package.json without installing them by using npm-add-dependencies
You can use it on-they-fly via npx, for example:
npx add-dependencies browser-sync-webpack-plugin#^2 browser-sync#^2 --dev
This will add browser-sync-webpack-plugin version ^2 and browser-sync version 2^ to devDependencies in your package.json

Install Single Dependency from package.json with yarn

I'm having a huge list of dependencies in my package.json and at some build step, which is completely independent from others, I only need to resolve a single dependency, but in the version specified in the package.json.
Is this even possible? A solution based on npm would also be fine.
I thought yarn add package-name --force could do it because it will determine the changes, but as there's no node_modules yet, it will also install everything first.

How do devDependencies work when you yarn add <package>?

If you have a project that depends on packageA and you yarn add packageA but packageA has a devDependency on packageB to build, shouldn't that cause packageA to not work for you? Since packageA won't be able to build unless its devDependencies are installed too?
I guess my main question is if a pacakge has a devDependency on a built tool like babel, how does it get built and work when it gets yarn added by a project? Shouldn't build tools like webpack be a normal dependency?
No, they shouldn't, because the package that is yarn added is already built in an environment where the devDependencies are available. For example, when a package needs babel or webpack to build, then during the publishing a built bundle is created in a CI/CD pipeline that is valid es5 code and that is what you pull from npm. No build required after that.
GOOD MORNING :)
If you are having dependency problems on your dependencies of package.json, it is very simple to solve =]
What happens is that the dependency modules that the modules of your project need (dependencies) must be installed in the global npm as a package node (module), that is:
npm install -g youPackageName
If you have already installed a module in other projects or in the current project and want to turn it into a global package, you can use the command:
npm link youPackageName