Skip to content

eject command on windows creates different path sepalators to package.json #1498

Closed

Description

@monamu

Description

After npm run eject on Windows , path sepalators in package.json are '\' (double back slash).

  • npm run eject on Windows

package.json

"setupFiles": [
  "<rootDir>\\config\\polyfills.js"
]
  • npm run eject on OS X

package.json

"setupFiles": [
  "<rootDir>/config/polyfills.js"
]

Expected behavior

"setupFiles": [
  "<rootDir>/config/polyfills.js"
]

path sepalator '/' is runs both (win/mac) environments.

Environment

  1. npm ls react-scripts (if you haven’t ejected):
    react-scripts@0.8.5

  2. node -v:
    v7.4.0

  3. npm -v:
    4.1.2

  4. Operating system:

Windows 7 64bit

Activity

  1. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

    Interesting, thanks. Do both variants work well, or is only / working?

  2. monamu commented on Feb 8, 2017

    @monamu
    Author

    / works on win and mac,

    but \\ works only on win.

  3. Timer commented on Feb 8, 2017

    @Timer
    Contributor

    Would something as simple as this work?

    diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js
    index b8f9d31..02e77ca 100644
    --- a/packages/react-scripts/scripts/eject.js
    +++ b/packages/react-scripts/scripts/eject.js
    @@ -145,7 +145,7 @@ prompt(
     
       fs.writeFileSync(
         path.join(appPath, 'package.json'),
    -    JSON.stringify(appPackage, null, 2)
    +    JSON.stringify(appPackage, null, 2).replace(/[\\]/g, '/')
       );
       console.log();
  4. monamu commented on Feb 8, 2017

    @monamu
    Author

    Patched eject.js outputs duplicate path sepalator....

        "setupFiles": [
          "<rootDir>//config//polyfills.js"
        ],
    

    But it works on windows 😄

  5. Timer commented on Feb 8, 2017

    @Timer
    Contributor

    Hmm.. that's odd that there's duplicates.

    > "<rootDir>\\config\\polyfills.js".replace(/[\\]/g, '/')
    '<rootDir>/config/polyfills.js'

    This should do it, @monamu:

    diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js
    index b8f9d31..cf8d5d7 100644
    --- a/packages/react-scripts/scripts/eject.js
    +++ b/packages/react-scripts/scripts/eject.js
    @@ -145,7 +145,7 @@ prompt(
     
       fs.writeFileSync(
         path.join(appPath, 'package.json'),
    -    JSON.stringify(appPackage, null, 2)
    +    JSON.stringify(appPackage, null, 2).replace(/[\\]+/g, '/')
       );
       console.log();
  6. monamu commented on Feb 8, 2017

    @monamu
    Author

    It worked fine 😃 @Timer

  7. added this to the milestone on Feb 10, 2017
  8. modified the milestones: 0.9.1, on Feb 11, 2017
  9. gaearon commented on Feb 26, 2017

    @gaearon
    Contributor

    This should be fixed in 0.9.2, please verify!

  10. monamu commented on Feb 27, 2017

    @monamu
    Author

    react-scripts@0.9.2 works fine on windows environment!
    and packege.json generated as intented.

  11. Timer commented on Feb 27, 2017

    @Timer
    Contributor

    Great, thanks for letting us know @monamu.

  12. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions