yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.37k stars 2.72k forks source link

bug: yarn link not working for monorepo setup #6801

Open IlCallo opened 5 years ago

IlCallo commented 5 years ago

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

marvinhagemeister commented 5 years ago

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)
oschade commented 5 years ago

Will there be an update for this?

rsoika commented 4 months ago

Have the same problem....