Yarn: bug: yarn link not working for monorepo setup

Created on 7 Dec 2018  路  2Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?
yarn link doesn't seem to work for monorepo setup, in this case expecially Angular Material monorepo.
See https://github.com/angular/material2/issues/14270

What is the expected behavior?
The symlink should work

Please mention your node.js, yarn and operating system version.
Node 10.13.0
yarn 1.12.3
OS: windows 10

triaged

Most helpful comment

We're running into a similar issue with preact@next. Our structure is like this:

/subpackage1
  /package.json
  /dist/...
/subpackage2
  /package.json
  /dist/...
/dist
package.json

Only the top-level module can be required when linking via yarn link. Neither of the sub-packages will work. This is the code that triggers the error:

const { Component } = require("preact");
const { useState } = require("preact/hooks"); // imports "preact"
console.log(Component, useState);

And the error itself:

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'preact'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/marvinh/dev/github/preact/hooks/dist/hooks.js:1:73)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)

All 2 comments

We're running into a similar issue with preact@next. Our structure is like this:

/subpackage1
  /package.json
  /dist/...
/subpackage2
  /package.json
  /dist/...
/dist
package.json

Only the top-level module can be required when linking via yarn link. Neither of the sub-packages will work. This is the code that triggers the error:

const { Component } = require("preact");
const { useState } = require("preact/hooks"); // imports "preact"
console.log(Component, useState);

And the error itself:

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'preact'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/marvinh/dev/github/preact/hooks/dist/hooks.js:1:73)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)

Will there be an update for this?

Was this page helpful?
0 / 5 - 0 ratings