Reputation: 1361
I'm building a site with yarn and hosting it on Netlify. I want to integrate another repo as a package, but I'd rather not put that package on the npm registry because it's very limited use. I hosted the package publicly via GitHub here and added it to my package.json
:
"dependencies": {
"@ourjapanlife/findadoc-localization": "^1.0.0",
.
.
.
}
I can build the site locally and everything runs fine. However, when I deploy to Netlify, I get the following error:
10:38:06 PM: [1/4] Resolving packages...
10:38:06 PM: error Couldn't find package "@ourjapanlife/findadoc-localization" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
10:38:06 PM: Error during Yarn install
I've created a .yarnrc
file as follows and added it to the root of my project:
@ourjapanlife:registry" "https://npm.pkg.github.com"
I've researched this a lot, but most of the advice relates to private GitHub repos. I'm fine with this package being public, but I don't want it centrally hosted because it's just some i18n files of little use to the wider community. This answer also looked promising, but switching from .npmrc
to .yarnrc
did not solve my issue.
Upvotes: 3
Views: 593
Reputation: 1361
A collaborator helped me resolve this by running:
yarn add https://github.com/ourjapanlife/findadoc-localization
And the resulting entry in package.json
looks like this:
"dependencies": {
"@ourjapanlife/findadoc-localization": "https://github.com/ourjapanlife/findadoc-localization",
.
.
.
}
At this point I could delete the .npmrc
/ .yarnrc
and remove the prenetlify
step.
It builds successfully on Netlify and resolved to the latest package via yarn.lock
.
It turns out in experimenting, I had switched between the npm and github registries and manually edited package.json. It's better to re-install via the command line.
Upvotes: 1