Skip to content

Bug in create-react-app scripts-version handling (scoped package + version) #2883

Closed
@rafales

Description

@rafales

Environment

➜  /tmp  node -v
v6.10.0
➜  /tmp  npm -v
5.0.3
➜  /tmp  yarn --version
0.27.5

OS: MacOS 10.12.5

Steps to Reproduce

  1. Fork create-react-app, publish package under a scope (@org/react-scripts)
  2. Try to specify custom scripts with a version create-react-app --scripts-version=@org/[email protected] hello

Expected Behavior

Project gets bootstrapped properly.

Actual Behavior

Error:

Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module '/private/tmp/hello/node_modules/@org/[email protected]/package.json'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at checkNodeVersion (/usr/local/lib/node_modules/create-react-app/createReactApp.js:479:23)
    at getPackageName.then.then.then.packageName (/usr/local/lib/node_modules/create-react-app/createReactApp.js:288:7)
    at process._tickCallback (internal/process/next_tick.js:103:7) code: 'MODULE_NOT_FOUND' }

Cause

There is a subtle bug in here:

https://github.com/facebookincubator/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L444

If I pass @org/react-scripts@version - indexOf() will return 0 (it returns position of the first occurrence).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions