question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage with yarn workspaces

See original GitHub issue

The error:

$ yarn run dev
yarn run v1.10.1

$ craco start
module.js:549
    throw err;
    ^

Error: Cannot find module 'C:\WebDev\coding-tracker\packages\client\node_modules\react-scripts/config/paths.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.resolve (internal/module.js:18:19)
    at resolveConfigFilePath (C:\WebDev\coding-tracker\node_modules\@craco\craco\lib\cra.js:24:20)
    at Object.<anonymous> (C:\WebDev\coding-tracker\node_modules\@craco\craco\lib\cra.js:38:26)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I’m using yarn workspaces for a monorepo, so all the node_modules is shared in a single folder. My app has a structrue like this:

coding-tracker/
├── node_modules/
└── packages/
    ├── api/
    ├── shared/
    └── client/

Now the problem is that craco looks for the react-scripts files in coding-tracker/packages/client/node_modules instead of coding-tracker/node_modules

I’m pretty sure that’s because process.cwd() would be coding-tracker/packages/client: https://github.com/sharegate/craco/blob/master/packages/craco/lib/paths.js#L4

I made a quick workaround in my case by doing this:

function getReactScriptsFolderPath() {
-   let filepath = "";
+   let filepath = "react-scripts";

-   if (args.reactScripts.isOverrided) {
-       filepath = path.resolve(`${projectRoot}/${args.reactScripts.value}/`);
-   } else {
-       filepath = path.resolve(`${nodeModulesPath}/react-scripts/`);
-   }

    log("Found react scripts folder at: ", filepath);

    return filepath;
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
axelchaloncommented, Feb 27, 2019

yes, https://github.com/axelchalon/craco-issue

Notice how yarn start works but yarn test doesn’t.

Some observations: tests work if there is only one test file, and tests work if I remove babel: {...} from the export of craco.config.js

1reaction
axelchaloncommented, Apr 4, 2019

Can confirm craco {test,build,start} all work fine with craco v4.0.0 and specifying reactScriptsPath in craco.config.js 👍 thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Workspaces - Yarn
Workspaces are a new way to set up your package architecture that's available by default starting from Yarn 1.0. It allows you to...
Read more >
Yarn workspaces — monorepo beginner's guide - Medium
Yarn Workspaces is a feature that allows users to install dependencies from multiple package.json files in subfolders of a single root package.json file,...
Read more >
Yarn Workspaces: Organize Your Project's Codebase Like A Pro
Yarn workspaces let you organize your project codebase using a monolithic repository (monorepo). The idea is that a single repository would ...
Read more >
Scaling out JavaScript Monorepos with Yarn Workspaces
The first thing to do is set up the workspaces. Start by ensuring that you're running the latest Yarn version. ... Next, initialize...
Read more >
Why should you use yarn workspaces? - DEV Community ‍ ‍
The Solution · It sets up a single node_modules without repetitions. · It allows you to change the code of one of your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found