mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-06-17 19:25:28 +08:00
Fix @type Installing
This commit is contained in:
42
packages/react-scripts/scripts/init.js
vendored
42
packages/react-scripts/scripts/init.js
vendored
@@ -107,14 +107,6 @@ module.exports = function(
|
||||
command = 'npm';
|
||||
args = ['install', '--save', verbose && '--verbose'].filter(e => e);
|
||||
}
|
||||
args.push(
|
||||
'react',
|
||||
'react-dom',
|
||||
'@types/node',
|
||||
'@types/react',
|
||||
'@types/react-dom',
|
||||
'@types/jest'
|
||||
);
|
||||
|
||||
// Install additional template dependencies, if present
|
||||
const templateDependenciesPath = path.join(
|
||||
@@ -131,19 +123,37 @@ module.exports = function(
|
||||
fs.unlinkSync(templateDependenciesPath);
|
||||
}
|
||||
|
||||
const types = [
|
||||
'@types/node',
|
||||
'@types/react',
|
||||
'@types/react-dom',
|
||||
'@types/jest',
|
||||
];
|
||||
|
||||
console.log(`Installing ${types.join(', ')} ${command}...`);
|
||||
console.log();
|
||||
|
||||
const proc = spawn.sync(command, args.concat(types), { stdio: 'inherit' });
|
||||
if (proc.status !== 0) {
|
||||
console.error(`\`${command} ${args.concat(types).join(' ')}\` failed`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Install react and react-dom for backward compatibility with old CRA cli
|
||||
// which doesn't install react and react-dom along with react-scripts
|
||||
// or template is presetend (via --internal-testing-template)
|
||||
// if (!isReactInstalled(appPackage) || template) {
|
||||
console.log(`Installing react and react-dom using ${command}...`);
|
||||
console.log();
|
||||
if (!isReactInstalled(appPackage) || template) {
|
||||
console.log(`Installing react and react-dom using ${command}...`);
|
||||
console.log();
|
||||
|
||||
const proc = spawn.sync(command, args, { stdio: 'inherit' });
|
||||
if (proc.status !== 0) {
|
||||
console.error(`\`${command} ${args.join(' ')}\` failed`);
|
||||
return;
|
||||
const proc = spawn.sync(command, args.concat(['react', 'react-dom']), {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
if (proc.status !== 0) {
|
||||
console.error(`\`${command} ${args.join(' ')}\` failed`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
// Display the most elegant way to cd.
|
||||
// This needs to handle an undefined originalDirectory for
|
||||
|
||||
Reference in New Issue
Block a user