Using Lerna with Unpublished Packages

I'm trying to create my monorepo with Lerna. The plan is to reorganize an existing project by pulling out pieces of code that should be their own packages. I launched lerna initand my current setup looks like this:

project/
  packages/
    new-refactored-package/
      package.json
    prior-existing-project/
      package.json
        { "dependencies" : { "new-refactored-package" : "latest" } }
  package.json
    {
      "devDependencies": {
        "lerna": "^2.0.0-rc.5"
      }
    }
  lerna.json
    {
      "lerna": "2.0.0-rc.5",
      "packages": [
        "packages/*"
      ],
      "version": "0.0.0"
    }

My understanding was what lerna bootstrapat this stage should find package1in the project and symbolically attach it to prior-existing-project /node_modules/new-refactored-package/. From lerna readme :

Download packages in the current Lerna repo. Installs all its dependencies and binds any cross-dependencies.

When launched, this command will:

  • npm installs all the external dependencies of each package.
  • Symlink integrates all Lerna packages that are dependent on each other.
  • npm provide all downloaded packages.

, , lerna npm install new-refactored-package:

npm ERR! 404 Registry 404 GET https://registry.npmjs.org/new-refactored-package

? npm?

+4
1

lerna bootstrap symlink , .

, , lerna version name .

...

project
- packages/
    - a_pkg
        - package.json {
            "name": "@scope/a_pkg",
            "version": "0.0.1",
            "private": true
            /// opt out
        }
    - b_pkg
        - package.json {
            "name": "@scope/b_pkg",
            "version": "0.0.1",
            "private": true,
            "dependencies": {
              "@scope/a_pkg": "^0"
            },
            /// opt out
        }
- package.json
- lerna.json {
    "packages": [
        "packages/*"
    ],
    /// opt out
}
+2

Source: https://habr.com/ru/post/1679015/


All Articles