Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails when package has no scripts #8291

Closed
renato-bohler opened this issue Jan 8, 2020 · 1 comment · Fixed by #8292
Closed

Build fails when package has no scripts #8291

renato-bohler opened this issue Jan 8, 2020 · 1 comment · Fixed by #8292

Comments

@renato-bohler
Copy link
Contributor

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.

const hasDeployScript = typeof appPackage.scripts.deploy !== 'undefined';

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.

@stale
Copy link

stale bot commented Feb 7, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Feb 7, 2020
@lock lock bot locked and limited conversation to collaborators Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants