Cannot use CRA to create a new yarn workspace/package
See original GitHub issueIs this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
No
Which terms did you search for in User Guide?
- “Yarn workspaces”
- “hoisting”
Environment
node -v
: v8.7.0npm -v
: 5.5.1yarn --version
(if you use Yarn): 1.2.1npm ls react-scripts
(if you haven’t ejected): N/A (happens on init)
Then, specify:
- Operating system: macOS Sierra v10.12.6
- Browser and version (if relevant):
Steps to Reproduce
(Write your steps here:)
mkdir cra-issue && cd cra-issue
- create a package.json using this:
{
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"husky": "^0.14.3"
}
}
yarn
create-react-app packages/app-a
Expected Behavior
A new CRA application to be initialized under packages/app-a
Actual Behavior
...
Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module '/Users/cra/Projects/sandbox/repro/packages/workspace-a/node_modules/react-scripts/package.json'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at checkNodeVersion (/Users/cra/.config/yarn/global/node_modules/create-react-app/createReactApp.js:488:23)
at getPackageName.then.then.then.packageName (/Users/cra/.config/yarn/global/node_modules/create-react-app/createReactApp.js:295:7)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting workspace-a / from /Users/cra/Projects/sandbox/repro/packages
Done.
Reproducible Demo
Use steps above
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:6 (4 by maintainers)
Top Results From Across the Web
CRA and Yarn Workspace
Recently, I wanted to set up a Typescript Create React App (CRA)in a Yarn workspace for my pet projects. I have gone through...
Read more >Workspaces
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 >How to import a common module in CRA using Yarn ...
I have one package based on create-react-app which should import from a common module (sibling package in the repo). This common package doesn't ......
Read more >React Monorepo Using Yarn Workspaces Only (No Lerna)
“Lerna calls yarn install multiple times for each package which creates overhead because each package.json is considered independent and they can't share ...
Read more >CRA with Yarn workspace and pnp : r/reactjs
I'm trying to combine Yarn workspaces + pnp + create-react-app + ... errors on the client workspace: variations of `Cannot find module ...
Read more >Top Related Medium Post
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone is stuck with this and until the different issues are fixed, I made a little guide on how to use yarn workspaces with Create React App and Create React Native App (Expo) to share common code across. Hope you find it handy! ~~https://learn.viewsdx.com/how-to-use-yarn-workspaces-with-create-react-app-and-create-react-native-app-expo-to-share-common-ea27bc4bad62~~ https://medium.com/viewsdx/how-to-use-yarn-workspaces-with-create-react-app-and-create-react-native-app-expo-to-share-common-ea27bc4bad62
Yea, we should really figure out a Workspaces integration. Also as a solution to the “absolute imports” problem.