Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 82881b7

Browse files
nikoantfacebook-github-bot
authored andcommitted
Yarn start Failed with "Error: Unable to resolve module react-redux" (#883)
Summary: Pull Request resolved: #883 #835 Reviewed By: passy Differential Revision: D20363818 fbshipit-source-id: 66b7cb7236c7b066db32473a9e993ba2ace529bc
1 parent 8a7e057 commit 82881b7

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

_watchmanconfig

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
{
2-
"ignore_dirs": ["node_modules", "build", "dist"]
32
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
]
233233
},
234234
"scripts": {
235-
"preinstall": "yarn config set ignore-engines",
235+
"preinstall": "node scripts/prepare-watchman-config.js && yarn config set ignore-engines",
236236
"postinstall": "cross-env TS_NODE_FILES=true node --require ts-node/register scripts/yarn-install.ts && patch-package",
237237
"rm-dist": "rimraf dist",
238238
"rm-modules": "rimraf node_modules static/node_modules",

scripts/prepare-watchman-config.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
const path = require('path');
11+
const util = require('util');
12+
const {exists: existsImport, copyFile} = require('fs');
13+
const exists = util.promisify(existsImport);
14+
15+
const rootDir = path.resolve(__dirname, '..');
16+
const hasGit = exists(path.join(rootDir, '.git'));
17+
18+
async function prepareWatchmanConfig(dir) {
19+
const hasWatchmanConfig = exists(path.join(dir, '.watchmanconfig'));
20+
if ((await hasGit) && !(await hasWatchmanConfig)) {
21+
console.log(`Creating .watchmanconfig in ${dir}`);
22+
await util.promisify(copyFile)(
23+
path.join(dir, '_watchmanconfig'),
24+
path.join(dir, '.watchmanconfig'),
25+
);
26+
}
27+
}
28+
29+
prepareWatchmanConfig(rootDir);
30+
prepareWatchmanConfig(path.join(rootDir, 'static'));

scripts/yarn-install.ts

-17
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import path from 'path';
1111
import util from 'util';
1212
import globImport from 'glob';
1313
import {exec as execImport} from 'child_process';
14-
import {exists as existsImport, copyFile} from 'fs';
1514
const glob = util.promisify(globImport);
1615
const exec = util.promisify(execImport);
17-
const exists = util.promisify(existsImport);
1816
const PACKAGES = [
1917
'headless-tests',
2018
'static',
@@ -28,9 +26,6 @@ const YARN_PATH =
2826
? path.join(__dirname, process.argv[2])
2927
: 'yarn' + (WINDOWS ? '.cmd' : '');
3028

31-
prepareWatchmanConfig(path.join(__dirname, '..'));
32-
prepareWatchmanConfig(path.join(__dirname, '..', 'static'));
33-
3429
Promise.all(
3530
PACKAGES.map(pattern =>
3631
glob(path.join(__dirname, '..', pattern, 'package.json')),
@@ -68,15 +63,3 @@ Promise.all(
6863
console.error(err);
6964
process.exit(1);
7065
});
71-
72-
async function prepareWatchmanConfig(dir: string) {
73-
const hasGit = exists(path.join(__dirname, '..', '.git'));
74-
const hasWatchmanConfig = exists(path.join(dir, '.watchmanconfig'));
75-
if ((await hasGit) && !(await hasWatchmanConfig)) {
76-
console.log(`Creating .watchmanconfig in ${dir}`);
77-
await util.promisify(copyFile)(
78-
path.join(dir, '_watchmanconfig'),
79-
path.join(dir, '.watchmanconfig'),
80-
);
81-
}
82-
}

static/_watchmanconfig

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
{
2-
"ignore_dirs": ["node_modules"]
32
}

0 commit comments

Comments
 (0)