{"id":8219,"date":"2020-06-11T23:06:24","date_gmt":"2020-06-11T23:06:24","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8219"},"modified":"2020-06-11T23:06:24","modified_gmt":"2020-06-11T23:06:24","slug":"how-to-yarn-link-when-the-package-is-not-published","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/how-to-yarn-link-when-the-package-is-not-published\/","title":{"rendered":"How to yarn link when the package is not published?"},"content":{"rendered":"<p>In the previous post we looked at using <em>yarn link<\/em> to work on development of a package whilst using it within our application (or other package).<\/p>\n<p>There&#8217;s a problem. This only works if you&#8217;ve previously published the package to an npm compatible repository because when you run <em>yarn<\/em> in your application, it&#8217;ll see the dependency of your package and try to get it from the remote repository.<\/p>\n<p>Note: this in not an issue if the package was published it&#8217;s only an issue for unpublished packages.<\/p>\n<p>What we can do is change the dependency from using a version number to essentially use a local path. For example, let&#8217;s assume we have the following in our packages.json<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n&quot;dependencies&quot;: {\r\n   &quot;@namespace\/package-name&quot;: &quot;1.0.0&quot;\r\n}\r\n<\/pre>\n<p>As stated, running <em>yarn<\/em> will result in and error <em>no such package available<\/em>. Changing this line to <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n&quot;dependencies&quot;: {\r\n   &quot;@namespace\/package-name&quot;: &quot;link:..\/dev\/package-name&quot;\r\n}\r\n<\/pre>\n<p>In other words, link: followed by the path to our package under development, then all will work, running <em>yarn<\/em> will no longer fail with the <em>no such package available<\/em> error.<\/p>\n<p>You also needn&#8217;t run the link commands on the package or application to create a symbolic link if you use this syntax, just remember to change it back to the version number once the package is published.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous post we looked at using yarn link to work on development of a package whilst using it within our application (or other package). There&#8217;s a problem. This only works if you&#8217;ve previously published the package to an npm compatible repository because when you run yarn in your application, it&#8217;ll see the dependency [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[242],"tags":[],"class_list":["post-8219","post","type-post","status-publish","format-standard","hentry","category-yarn"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8219"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8219\/revisions"}],"predecessor-version":[{"id":8225,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8219\/revisions\/8225"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}