Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #8291
Closed
Open
Issue created Jan 08, 2020 by Administrator@rootContributor

Build fails when package has no scripts

Created by: renato-bohler

Describe the bug

When running react-scripts build the build fails if:

  • the project has no scripts on its package.json AND
  • the public pathname is set (via "homepage" on package.json or the PUBLIC_URL env variable) AND
  • the public pathname contains .github.io/

This might happen if one is using yarn workspaces and all scripts of the React application are declared on the workspace root package.

It seems that the problem lies on printHostingInstructions.js, as it tries to access deploy of scripts without checking if scripts exists first.

https://github.com/facebook/create-react-app/blob/915108b650635c28a96e0f5c9eedf672ee8ec0b1/packages/react-dev-utils/printHostingInstructions.js#L25

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

  • build
  • deploy
  • PUBLIC_URL
  • homepage
  • scripts

Environment

npx: installed 91 in 5.921s

Environment Info:

  System:
    OS: Linux 5.3 Linux Mint 19.3 (Tricia)
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  Binaries:
    Node: 8.17.0 - /usr/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.13.4 - /usr/bin/npm
  Browsers:
    Chrome: 79.0.3945.88
    Firefox: 71.0
  npmPackages:
    react: ^16.12.0 => 16.12.0 
    react-dom: ^16.12.0 => 16.12.0 
    react-scripts: 3.3.0 => 3.3.0 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Clone create-react-app
  2. Run yarn
  3. Run PUBLIC_URL=http://any.thing yarn build

OR

  1. Clone this repository
  2. Run yarn
  3. Run PUBLIC_URL=http://renato-bohler.github.io/my-app yarn build

Expected behavior

Build shouldn't fail.

Actual behavior

Build is failing with the message:

Cannot read property 'deploy' of undefined

Note that without setting PUBLIC_URL, the problem doesn't occur:

image

Reproducible demo

cra-build-issue, as mentioned on "Steps to reproduce", or create-react-app itself.

Assignee
Assign to
Time tracking