Jalal
Jalal

Reputation: 3624

Use local lerna packages as scripts on the root folder

I have several packages inside scripts that used in root.

I use npm link scripts/babel-preset which enables me to use the preset in the main babel.config.js and I wonder if this is the right way to do it or I miss the obvious here?

root
|-- packages/
|-- scripts
    |-- babel-preset
|-- babel.config.js
|-- package.json
|-- lerna.json

I am aware of lerna bootstrap but it works in sub-folders between siblings. My issue is using packages in root.

Is there anyway to use scripts in the root without using npm link for every single package?

Thank You.

Upvotes: 0

Views: 939

Answers (1)

Jalal
Jalal

Reputation: 3624

In root package.json I added required scripts as local devDependencies:

{
    ...
    "devDependencies": {
        ....
        "babel-preset": "file:scripts/babel-preset",
        ....
    }
}

It works fine with npm install

UPDATE:

If you are using yarn you don't need any internal link. Yarn will take care of everything.

Upvotes: 2

Related Questions