Yarn install inside a monorepo without links - yarn-workspaces

We have a service inside a monorepo project, we want to install only that service.
We are able to install the node_modules inside that service folde (rather than at the root folder) when adding the following to package.json:
"installConfig": {
"hoistingLimits": "workspaces"
}
That's great, but some of the dependencies are links to other local packages in the repo.
Is there a way to force yarn to 'deep copy' the dependencies in the node_modules folder?

Related

How to install node_modules only one time for one React JS project?

As I am implementing release automation of React JS project using Jenkins, it is required to download node_modules for a project only once and update successively. It doesn't mean one node_ modules for all projects. But one-time install for one project.
For example, Let's consider a project LoginReactApp.
I have to maintain a workspace like D:/jenkins/workspace/LoginReactApp.
So, I have to check out the source under D:/jenkins/workspace/LoginReactApp/LoginReactApp
and based on the package.json file, I need to download it under D:/jenkins/workspace/LoginReactApp/.
After the release process, the LoginReactApp project source will be deleted under D:/jenkins/workspace/LoginReactApp/ and the node_modules folder will not be deleted.
So, next time it is enough to check out only LoginReactApp project source D:/jenkins/workspace/LoginReactApp/ and it refers to already installed node_modules.
I have tried in command prompt below.
D:/jenkins/workspace/LoginReactApp/LoginReactApp>npm install
--production --f --prefix D:/jenkins/workspace/LoginReactApp/
Is it right? For next time it behaves differently.
How to install node_modules only one time for one React JS project?

Is there a way to install dependencies for just one package in a yarn2 monorepo?

to do a yarn immutable install for all packages it yarn 2 recommends yarn workspaces focus --production --all, is there a way to do this for just one workspace? reason being I would like to not have all dependencies for everything installed into docker containers for different applications.
Yes,
yarn workspaces focus --production (without --all flag)
installs production dependencies just for the workspace in current working directory. You can also specify the name of the workspace as an argument, e.g.:
yarn workspaces focus --production frontend

Does not load scripts in node_modules folder

I have a asp.net mvc 5 project that utilizes npm for package management.
I include node_modules directory in output and publish my project.
I then upload my project on a plesk host.
The file(s) in the Script directory load successfully, however files that are in the node_modules directory do not load.
When I rename the node_modules directory to Modules it fixes the problem. However, this is not my answer.
Where is problem? plesk does not find node_modules?
Is there some permission policy in plesk that may be causing this issue?
Why do you want to pack the node_modules? Is it not supposed to be installed by npm based on your package.json dependencies when your package is being installed or brought in as a dependency by other packages ¯_(ツ)_/¯
On a side note, even if you want to pack node_modules, is there an .npmignore or a .gitignore having a node_modules entry in it?

Electron doesn't install all packages inside package.json

Electron packager has packaged my app.But it doesn't have all the node modules as present in my app before packaging. I am forced to manually run npm install inside my packaged folder.
So, the app is not able to perform as expected.
I tried inside package.json
"build": {
"files": [
"/node_modules/**",
"package.json"
]
}
It looks like you are using your package.json wrong way.
Only "dependencies" will be included to the build if you put some package to "devDependencies" it will be excluded from the build.
use no-prune in build using electron packager and place all the modules inside devDependencies and then build the app.

Managing bower dependencies with ionic

After starting with a new ionic app, I can see at bower.json that comes with ionic is in devdependencies. Why is it a devdependency and not a normal dependency?
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.0.0-rc.0"
},
Thanks, I feel confused right now
having devDependencies gives you the opportunity to simplify the steps that drive you from the source files (a git clone of the project) to the production ready app
when you don't need to make changes and (develop) the application, you could just run
bower install --production
or
npm install --production
they work the same
bower install options
-F, --force-latest: Force latest version on conflict
-p, --production: Do not install project devDependencies
-S, --save: Save installed packages into the project’s bower.json dependencies
-D, --save-dev: Save installed packages into the project’s bower.json devDependencies
-E, --save-exact: Configure installed packages with an exact version rather than semver
bower documentation
npm install options
By default, npm install will install all modules listed as
dependencies. With the --production flag (or when the NODE_ENV
environment variable is set to production), npm will not install
modules listed in devDependencies.
npm documentation
This way you take less time to ship the app and don't waste bandwidth downloading stuff you won't need.
Given that, to me, the choice of listing ionic as devDependecy is a poor one: it implies that I could take advantage of this choice to get ready the app for execution this way:
git clone my-project
git cd my-project
npm install --production # ionic not installed here
ionic state restore
ionic build ios
Now, if you ignore the content of /lib folder in your sources, this should not work, and if it works because the ionic-cli does some more checks to save your ass, I think this is unclear.
From what I understand, dependencies are required to run, and devDependencies are only for development, like minification, unit tests, etc.
Both will install when you do npm install but only dependencies will install when you do npm install $package, unless you add the --dev option

Resources