Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const validateProjectName = require('validate-npm-package-name');

const packageJson = require('./package.json');

// Environments behind corporate proxies require NO_UPDATE_NOTIFIER variable
// for npm to work in child_process
const npmExecOptions = { env: { ...process.env, NO_UPDATE_NOTIFIER: 'true' } };

let projectName;

function init() {
Expand Down Expand Up @@ -195,7 +199,9 @@ function init() {
checkForLatestVersion()
.catch(() => {
try {
return execSync('npm view create-react-app version').toString().trim();
return execSync('npm view create-react-app version', npmExecOptions)
.toString()
.trim();
} catch (e) {
return null;
}
Expand Down Expand Up @@ -772,7 +778,7 @@ function checkNpmVersion() {
let hasMinNpm = false;
let npmVersion = null;
try {
npmVersion = execSync('npm --version').toString().trim();
npmVersion = execSync('npm --version', npmExecOptions).toString().trim();
hasMinNpm = semver.gte(npmVersion, '6.0.0');
} catch (err) {
// ignore
Expand Down Expand Up @@ -1009,7 +1015,9 @@ function getProxy() {
} else {
try {
// Trying to read https-proxy from .npmrc
let httpsProxy = execSync('npm config get https-proxy').toString().trim();
let httpsProxy = execSync('npm config get https-proxy', npmExecOptions)
.toString()
.trim();
return httpsProxy !== 'null' ? httpsProxy : undefined;
} catch (e) {
return;
Expand Down