Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a monorepo without hosting on a package registry and installing via bitbucket

At my organization, we are trying to create a monorepo of react components so they can be used on several sites.

We currently have a repo called react-components hosted on bitbucket and we wanted to set it up as a monorepo using lerna.js so the structure would look like

packages
    package_1
         package.json
         dist
    package_2
         package.json
         dist

However we don't host our npm packages on a registry but rather bitbucket and install them from there

so I'd like to be able to install each package into our websites via package.json like

"@company_name/react_components/package_1": "git+ssh://[email protected]_name.com:7999/np/react-components.git#personal/jdaly/testBranch",

however I don't think you can have that path in a package.json so it should be more like

"@company_name/react_components": "git+ssh://[email protected]_name.com:7999/np/react-components.git#personal/jdaly/testBranch",

and import like

import package_1 from "@company_name/react_components"

is it possible to set up a monorepo without using a package registry and just import all the monerepo packages via a git link? Haven't found much information on the web

I followed this tutorial https://blog.npmjs.org/post/186494959890/monorepos-and-npm But you're still importing your modules/packages via a package registry rather thank installing via a git link

After I build my packages I push them to the repo and in my website package.json I am referencing it like so

"@company_name/react-components": "git+ssh://[email protected]_name.com:7999/np/react-components.git#personal/jdaly/firstCommit",

and when I go to node_modules the structure is

node_modules
     @company_name
          react_components
               packages
                    package_1
                    package_2
                    package_3
               lerna.json
               package.json

when it should be

node_modules
     @company_name
          react_components
                    package_1
                    package_2
                    package_3

Any help appreciated

like image 366
James Daly Avatar asked Jul 30 '19 16:07

James Daly


1 Answers

To anyone who stumbles upon this question - the answer is simple. In order to use lerna and create a monorepo system you need to have a package registry. That could be NPM or another product like https://verdaccio.org/ which is essentially a package registry you can use locally

like image 102
James Daly Avatar answered Sep 30 '22 12:09

James Daly