A
A
Alexey Yarkov2021-04-15 19:51:25
JavaScript
Alexey Yarkov, 2021-04-15 19:51:25

Why is lerna executing a command in a temporary directory?

There is a monorepa with lerna on board.
There is a package in this turnip packages/browser-validator.
The package has a hook preparethat executes yarn build.
It was conceived in such a way that at the time of installing the package, build it and not store the build files in the repository.
If you execute in monorep yarn install, then everything works as it should, the build is collected in the directory packages/browser-validator/dist

There is a project in which monorep is used as a dependency

// package.json проекта
"dependencies": {
    "@frontend/core": "git+ssh://[email protected]/frontend/core.git",
}


Execute in a projectyarn install
// лог из терминала
yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ lerna run --stream --sort prepare
lerna notice cli v4.0.0
lerna info Executing command in 1 package: "yarn run prepare"
browser-validator: yarn run v1.22.5
browser-validator: $ yarn build
browser-validator: $ run-s build:js build:pug:*
browser-validator: $ cross-env NODE_ENV=production rollup -c rollup.config.js
browser-validator: src/main.js → dist/main.js...
browser-validator: created dist/main.js in 1.3s
browser-validator: $ pug --pretty --out ./dist --obj ./src/lang-resources/ru.json src/templates/ie-ru.pug
browser-validator:   rendered /home/user/.cache/yarn/v6/.tmp/496ddf2cf95cfa229315794edfe291a4.c48e743c78c6014987c0ca4b2b560662464349a9.prepare/packages/browser-validator/dist/ie-ru.html
browser-validator: $ pug --pretty --out ./dist --obj ./src/lang-resources/en.json src/templates/ie-en.pug
browser-validator:   rendered /home/user/.cache/yarn/v6/.tmp/496ddf2cf95cfa229315794edfe291a4.c48e743c78c6014987c0ca4b2b560662464349a9.prepare/packages/browser-validator/dist/ie-en.html
browser-validator: Done in 3.28s.
lerna success run Ran npm script 'prepare' in 1 package in 3.4s:
lerna success - browser-validator


The hook works, but the build does not occur in
./node_modules/@frontend/core/packages/browser-validator/dist
, and in
/home/user/.cache/yarn/v6/.tmp/496ddf2cf95cfa229315794edfe291a4.c48e743c78c6014987c0ca4b2b560662464349a9.prepare/packages/browser-validator/dist
.

How to force to execute a command in the project directory?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question