How to resolve workspace node_modules - yarnpkg

I have a mono-repo that contains the main code, and some custom packages as workspaces.
so my directory structure is like this
- mainRepo
-- directories of main project
-- /node_modules
-- /packages
--- my-foo-package
---- /node_modules
so since the workspace (my-foo-package in this case) has its own node_modules, every dependency that it has is going to be there
but main repo also needs the workspace dependencies too, to be able to import codes from workspace package
but after i added the workspace package, linked it and added it to main repo dependencies and ran yarn install i still cannot see the dependencies of workspace package in roo node_modules
is there any step missing?

Related

Problem that clone project cannot be run due to gitignore

I'm using gitignore, and I'm good at push and pull for personal management.
The focus is on my own creation, so I have all the configuration files, so it runs well locally.
However, if I "Clone" this project and download it to an empty folder, it cannot be run anywhere.
It seems as if there is no configuration file necessary for project configuration or server execution.
I am attaching my gitignore.
Is this what gitignore originally intended?
I want to clone a project so that it can run.
Do I have to delete gitignore to do that?
p.s If I delete gitignore and clone all projects (including build artifacts) it works fine.
use tool & etc : Intellij, Spring, Tomcat
### Java template
*.class
# Package Files #
*.jar
*.war
*.ear
### macOS template
*.DS_Store
.AppleDouble
.LSOverride
# IntelliJ project files
.idea
.idea/*.xml
*.iml
out
gen
build
rebel.xml
# Compliled files
/target/
**/target
/example/
# Gradle
.gradle
/build/
.gradletasknamecache
Normally, you don't distribute compiled binaries with your git repo. The convention is to either have users compile the code locally, or distribute that code using a package management system like Maven, Ivy, npm, Nuget, pip or gem. This isn't a hard and fast rule however.

Prevent yarn from creating node_modules in monorepo root

I'm using yarn with monorepos that contain several packages. For examples packages foo and bar might be located in repo/foo and repo/bar within the monorepo root repo. The problem is that I sometimes accidentally run yarn without parameters in the repository root instead of the packages directories. This creates a repo/node_modules directory and a repo/yarn.lock file. Can I somehow prevent yarn from creating node_modules and yarn.lock in the repository root directory?

How to remove yarn workspaces correctly?

I configured 2 workspaces in package.json e.g example and gatsby-theme but later I found I was actually developing a gatsby-starter so I removed the example workspace that depended on the latter workspace from package.json.
I wonder if I moved all files from gatsby-theme/ to the project root directory and overwrote the package.json and other files with gatsby-theme's, does it become a project that could be managed with both npm and yarn?

How to `yarn run start` providing custom modules location

Here is my problem, I constructed a dockerfile launching yarn install from a folder where a package.json and yarn.lock are present (they have been taken from the project I have to setup yarn dependencies for, this project is inside a deconnected server).
Then, I run bash into container image and uploaded the created folder node_modules, and put it into the deconnected server, where project is present, at root folder project.
But then, when I launched yarn start from root folder, it says that it cannot find rescripts despite of the fact that folder #rescripts is present into node_modules.
I tried NODE_PATH=./node_modules yarn start without any success.
Thanks a lot for your help.
Regards
I think i get what i want with :
https://yarnpkg.com/blog/2016/11/24/offline-mirror/
I create a cache folder with all tar.gz dependencies downloaded.
But if i remove node_modules and yarn.lock, and run yarn install --offline --cache-folder npm-packages-offline-cache/, I got error saying it could not find proper dependance in cache folder. It's like it cannot recognize any tar.gz inside. Any help will be welcome.
Regars

How to override vendor packages with local src in dep (for local development)

Pseudo project setup:
$GOPATH/src/github.com/foo/common-libs
$GOPATH/src/github.com/foo/my-project (has a dependency on common-libs managed by dep, copy in /vendor directory
Can't find a way to edit common-libs locally (i.e. in /src) and have those changes immediately reflected in my-project. The project /vendor file always has priority over that in $GOPATH.
Instead every time I need to push the common-libs changes to Github then run dep ensure -update in my-project -- which is really slow and annoying.
Tried (unsuccessfully):
Ignoring local /vendor in Gopkg.toml using ignored = ["github.com/foo/common-libs*"], but throws a compilation error: cannot use &amount (type *"github.com/foo/my-project/vendor/github.com/shopspring/decimal".Decimal) as type *"github.com/foo/common-libs/vendor/github.com/shopspring/decimal".Decimal in field value)
Manually deleting common-libs from the /vendor directory of my-project (temporarily) -- but this leads to the same compilation error as #1 (and is annoying because running dep ensure adds the deleted folder back to the vendor folder).
Manually editing common-libs in /vendor (temporarily), which works -- but I lose static code analysis and I have to copy the changes to the actual common-libs projects afterwards.
Any help appreciated! Thanks.

Resources