Packages

create-react-app

5.1.0 · 15 Feb 2025MIT34.4k / weekRepositoryHomepagenpmAtom feed

Your version

1.0.0

major3 Dec 2016Where it was published

1.5.2 is the newest release of 1.x.

In short

10 breaking43 new32 fixed26 changed11 internal

  • Breaking

    Please refer to the Jest 19 and Jest 20 breaking changes for migration instructions.

  • Breaking

    react-dev-utils, react-scripts: Add ModuleScopePlugin to ensure files reside in src/. (@Timer)

  • Breaking

    react-scripts: Ignore Moment.js locales by default. (@gaearon)

  • Breaking

    react-scripts: Only run tests in src/ (#544). (@motevets)

  • Breaking

    react-scripts: Some flexbox bugs are autofixed, and support for 2009 spec is dropped. (@cr101)

  • Breaking

    react-scripts: Upgrade to Jest 19 (now 20). (@rogeliog)

  • Breaking

    react-scripts: Whitelist files that can be embedded through url-loader. (@pugnascotia)

  • Breaking

    eslint-config-react-app, react-dev-utils: Tweak lint rules. (@gaearon)

Release note

We’ve been working on this release for the past few months, and there are many big impovements, from migrating to webpack 2 to a brand new runtime error overlay and built-in support for Progressive Web Apps.

So instead of just enumerating them here, we decided to write a blog post about all the new features.

Check it out: What’s New in Create React App.

Have you read it? Now let's see how to update your app to the latest version.

Migrating from 0.9.5 to 1.0.0

First, ensure you are using the latest Node 6 LTS or newer. In 1.0.0, we have dropped support for Node 4 and NPM 2.

Inside any created project that has not been ejected, run:

npm install --save-dev --save-exact react-scripts@1.0.0

You may also optionally update the global command-line utility for bug fixes:

npm install -g create-react-app

Ensure application and test files reside in src/

We've never supported importing files from outside src/, nor have we supported running tests outside of src/.
We also never explicitly forbid doing so, which caused confusion when things didn't work like they should.

When running or building your application, you may see a message like so:

You attempted to import ... which falls outside of the project src/ directory.

To remedy this, simply move any files that you import within src/ and update your relative imports accordingly. This enforces that files that import each other stay in src/, and other folders serve different purposes (e.g. the public/ folder just gets served from the root).

If you used relative imports outside the project directory as a way to share code with another project, consider using a monorepo instead, so that other projects are symlinked to your project's node_modules/. Then you can import them as a Node modules.

While running npm test, you may notice some of your tests are missing. Please move any top-level test directory (i.e. __test__, __spec__) or files (i.e. *.test.js, *.spec.js) into src/. Conversely, if you have some similarly named files that you don’t want Jest to run, move them outside of src/.

Import required locales for Moment.js

Moment.js locales are now purposely excluded from the bundle unless explicitly depended on.

Please import the locales you need:

import moment from 'moment';
import 'moment/locale/fr';
import 'moment/locale/es';

You can no longer import file content

You can no longer import a file and expect to receive its contents as an encoded string.
This behavior was confusing and inconsistent depending on the file size.

Importing files with unknown extensions will now always include them into the build and return a valid URL.

If you'd like to import a file's contents as a string, consider contributing to #1944.
For the time being, you must embed assets within an export:

// sample.txt
export default `i want
this data as a string
`;

You can then import this as so:

import sampleText from './sample.txt';

// ...

Confusing window globals can no longer be used without window qualifier

Please prefix any global method with window., you may experience this with methods such as confirm.

Simply update references from confirm to window.confirm.

Note that this new lint error will likely uncover legitimate accidental uses of global variables where you meant to define a local variable instead.

Why is my import erroring out?

You can no longer use AMD import syntax, nor define an import anywhere other than the top of the file.

This is to reduce confusion around import statements, which do not allow you to evaluate code between them.

I see many accessibility warnings

We have enabled a new set of rules to help make applications more accessible, please take time to learn about the errors and fix them.

You can search for every lint rule name in the right column and read its description on the web. The fixes are usually very simple.

I see many warnings about PropTypes and createClass

We have enabled the lint warnings about React APIs deprecated in React 15.5.
You can automatically convert your project to fix them by running the corresponding codemods.

How do I make my tests work with Jest 20?

Please refer to the Jest 19 and Jest 20 breaking changes for migration instructions.

If you use snapshots, you will likely need to update them once because of the change in format.

Flexbox 2009 spec is no longer polyfilled

The old, 2009 specification for Flexbox is deprecated and is 2.3x slower than the latest specification.

We are no longer polyfilling it automatically.

I see "Definition for rule 'jsx-a11y/alt-text' was not found (jsx-a11y/alt-text)" in the editor

Follow these steps if you see errors about missing lint rules in the editor.

  1. Ensure that in your editor ESLint settings you have "Use Global ESLint" turned off

  2. Run npm install in your project (or yarn)

  3. Quit your editor completely (ensure its process doesn't hang around)

  4. Start the editor again

If you still have the problem please file an issue.

How to turn my app into a Progressive Web App?

After the regular update procedure above, add these line to <head> in public/index.html:

    <meta name="theme-color" content="#000000">
    <!--
      manifest.json provides metadata used when your web app is added to the
      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">

Then create a file called public/manifest.json that looks like this:

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

Finally, create src/registerServiceWorker.js with this template, import it from src/index.js and call the function it exports.

Anything missing?

This was a large release, and we might have missed something.

Please file an issue and we will try to help.

Some of my tests started crashing because of unhandled rejections

Unhandled Promise rejections will now crash tests. You can fix them by explicitly catching the errors you don’t care about.

Detailed Changelog

For a readable summary of the changes, check out our blog post.

:boom: Breaking Change

  • Breaking

    react-dev-utils, react-scripts: Add ModuleScopePlugin to ensure files reside in src/. (@Timer)

  • Breaking

    react-scripts: Ignore Moment.js locales by default. (@gaearon)

  • Breaking

    react-scripts: Only run tests in src/ (#544). (@motevets)

  • Breaking

    react-scripts: Some flexbox bugs are autofixed, and support for 2009 spec is dropped. (@cr101)

  • Breaking

    react-scripts: Upgrade to Jest 19 (now 20). (@rogeliog)

  • Breaking

    react-scripts: Whitelist files that can be embedded through url-loader. (@pugnascotia)

  • Breaking

    eslint-config-react-app, react-dev-utils: Tweak lint rules. (@gaearon)

  • Breaking

    eslint-config-react-app, react-error-overlay, react-scripts: Upgrade eslint-plugin-jsx-a11y and activate more rules. (@AlmeroSteyn)

  • Breaking

    eslint-config-react-app, react-scripts: Confusing global variables are now blacklisted. (@doshisid)

:rocket: New Feature

  • react-scripts: Scaffolded applications are now Progressive Web Apps by default. (@jeffposnick)

  • react-scripts: Support multiple env configuration files. (@tuchk4)

  • react-scripts: Enable CSS sourcemaps in production. (@gaearon)

  • react-scripts: Make subset of Jest options overridable. (@ryansully)

  • react-dev-utils, react-scripts: Add react-error-overlay, our new crash overlay. (@Timer)

  • react-dev-utils, react-scripts: Support specifying a node script as BROWSER environment variable. (@GAumala)

  • react-dev-utils, react-scripts: Support multiple proxies in development. (@jamesblight)

  • eslint-config-react-app, react-scripts: Upgrade eslint-plugin-jsx-a11y and activate more rules. (@AlmeroSteyn)

:bug: Bug Fix

  • react-scripts: Improve interaction between compile and runtime overlays (@gaearon)

  • react-scripts: Disable Uglify reduce_vars. (@gaearon)

  • react-scripts: Support hoisting react-scripts and add require.resolve() to loaders. (@gaearon)

  • react-scripts: Do not respect .eslintignore. (@Timer)

  • react-scripts: Ignore yarn cache directory when searching for tests. (@jmorrell)

  • react-scripts: Name development chunk names. (@herrstucki)

  • react-scripts: Minify CSS post-webpack 2. (@viankakrisna)

  • react-scripts: Resolve localhost when offline (Windows). (@bunshar)

  • react-scripts: Bind to host environment variable. (@GAumala)

  • react-scripts: Ensure proxy url starts with http:// or https://. (@bunshar)

  • react-scripts: Upgrade detect-port. (@Andreyco)

  • react-scripts: Fix default responsive behavior in iOS 9+. (@GreenGremlin)

  • react-scripts: Makes end-to-end testing crash on unhandled rejections. (@dbismut)

  • react-scripts: Fixes a silent crash when ejecting. (@gaearon)

  • react-scripts: Fix ejecting from a scoped fork. (@gaearon)

  • react-dev-utils: openBrowser now supports urls with more than one parameter. (@alisonmonteiro)

  • react-dev-utils: Fix openBrowser() when BROWSER=open on macOS. (@bpierre)

  • react-dev-utils: Fix an edge-case for people with the username cwd. (@chrisdrackett)

  • create-react-app: Check internet connectivity with lookup instead of resolve. (@kdleijer)

  • create-react-app: Show package name in CLI. (@mkazantsev)

  • create-react-app: Properly extract package name for installing a tgz of scoped packages. (@Timer)

  • create-react-app: Add diagnostic code. (@tgig)

  • create-react-app: Fix project cleanup on Windows. (@johann-sonntagbauer)

  • create-react-app: Add project name validation. (@johann-sonntagbauer)

  • create-react-app: Fix react dependency versions during initial install. (@johann-sonntagbauer)

:nail_care: Enhancement

  • react-dev-utils, react-scripts: Refactor and improve build output. (@gaearon)

  • react-dev-utils, react-scripts: Tweak error and warning output. (@gaearon)

  • react-dev-utils, react-scripts: Replace prompt function Inquirer.js. (#1767). (@iansu)

  • react-dev-utils, react-scripts: Extract generic build functions to react-dev-utils. (@viankakrisna)

  • react-dev-utils, react-error-overlay: Tweak error overlay styles. (@bvaughn)

  • react-scripts: Ignore Moment.js locales by default. (@gaearon)

  • react-scripts: Adding plugin postcss-flexbugs-fixes and flexbox: 'no-2009' to Autoprefixer. (@cr101)

  • react-scripts: Upgrade to Jest 19 (now 20). (@rogeliog)

  • react-scripts: Removed redundant UglifyJS options. (@marcofugaro)

  • react-scripts: Suggest yarn build instead of yarn run build. (@geoffdavis92)

  • react-scripts: Suggest serve for running in production. (@leo)

  • react-scripts: Display yarn instead of yarnpkg when creating a new application. (@lpalmes)

  • react-scripts: Modularise scripts. (@djgrant)

  • react-scripts: Add X-FORWARDED headers for proxy requests. (@johann-sonntagbauer)

  • eslint-config-react-app, react-dev-utils: Tweak lint rules. (@gaearon)

  • react-error-overlay, react-scripts: Use Jest 20. (@gaearon)

  • babel-preset-react-app, eslint-config-react-app, react-dev-utils, react-error-overlay, react-scripts: Bump dependencies. (@gaearon)

  • eslint-config-react-app: Removing a stylistic lint rule. (@anilreddykatta)

  • eslint-config-react-app: disable ignoring unused vars prefixed with _. (@doshisid)

  • eslint-config-react-app: Relax label rules (Closes #1835). (@anilreddykatta)

  • eslint-config-react-app: Remove 'guard-for-in' lint rule. (@spicyj)

  • eslint-config-react-app, react-scripts: Blacklist confusing global variables. (@doshisid)

  • eslint-config-react-app, react-scripts: Bump jsx-a11y version. (@bondz)

  • eslint-config-react-app, react-scripts: Add support for ignoreRestSiblings in no-unused-vars. (@chrisdrackett)

  • react-dev-utils: Only show the first compilation error. (@gaearon)

  • react-dev-utils: Omit ESLint warnings when there are ESLint errors. (@gaearon)

  • react-dev-utils: Prettify errors and warnings for Webpack 2. (@gaearon)

  • react-dev-utils: Modularize and extract crash overlay to iframe. (@Timer)

  • create-react-app: Allow creation of apps in empty Mercurial repos. (@GreenGremlin)

  • Other

:memo: Documentation

  • react-scripts: Remove live-editing since isn't accurate. (@cesarvarela)

  • react-scripts: Update Sass README. (@kellyrmilligan)

  • react-scripts: Fixed link for storybook. (@scottrangerio)

  • react-scripts: Fix instructions for serving with now. (@davidascher)

  • react-scripts: Clarify .eslintrc effects. (@luftywiranda13)

  • react-scripts: Suggest to create .eslintrc for IDE lint plugins. (@gaearon)

  • react-scripts: Fix Netlify heading level. (@benpickles)

  • react-scripts: Suggest node-sass alternative. (@michaelwayman)

  • react-scripts: Update doc server example to work from any directory. (@isramos)

  • react-scripts: Update information in User Guide for Enzyme dependency. (@josephrace)

  • react-scripts: Suggest Yarn in HTML template. (@tmos)

  • react-scripts: User Guide: Removed blockquote from code section, due to markdown conflict. (@stochris)

  • react-scripts: Add Yarn steps for adding flow. (@zertosh)

  • react-scripts: Update now.sh deployment instructions. (@replaid)

  • react-scripts: Add docs for apache's client side routing setting. (@viankakrisna)

  • react-scripts: Suggest to use .env for enabling polling mode. (@gaearon)

  • react-scripts: Fixed missing --recursive flag in first npm run watch-css command. (@mklemme)

  • react-scripts: Set Chrome userDataDir to be under .vscode folder. (@ryansully)

  • Other

  • babel-preset-react-app: Update side-effect documentation. (@evenchange4)

:house: Internal

  • react-scripts: Use some ES6 syntax. (@shashkovdanil)

  • react-scripts: Add linked modules test. (@Timer)

  • react-scripts: Fix eject for linked react-scripts. (@tuchk4)

  • react-scripts: Fix internal linting setup. (@gaearon)

  • react-scripts: Remove unused url import in Webpack config. (@pd4d10)

  • react-scripts: Update extract-text-webpack-plugin to stable. (@SimenB)

  • react-dev-utils, react-scripts: Move more logic from react-scripts to react-dev-utils. (@gaearon)

  • react-dev-utils, react-scripts: Add custom eslint formatter. (@doshisid)

  • babel-preset-react-app, react-scripts: Resolve regenerator runtime relative to react-scripts. (@gaearon)

  • babel-preset-react-app, react-scripts: Re-disable babel modules transform. (@Timer)

  • babel-preset-react-app, react-scripts: Switch to preset-env. (@Timer)

  • create-react-app, react-dev-utils, react-scripts: Bump minimal Node version to 6. (@ianschmitz)

  • Other

  • babel-preset-react-app, create-react-app, eslint-config-react-app, react-dev-utils, react-scripts: Update to modern code style (ES6). (@tuchk4)

  • eslint-config-react-app: Relax ESLint config peerDependency. (@gaearon)

  • eslint-config-react-app, react-dev-utils, react-scripts: Lint internal scripts with eslint:recommended. (@gaearon)

  • react-dev-utils: Don't use ES6 in a file that should run on Node 4. (@gaearon)

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.