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

npm error: --watch is not supported without git/hg, please use --watchAll #282

Closed
emoriarty opened this Issue Mar 22, 2018 · 6 comments

Comments

6 participants
@emoriarty

emoriarty commented Mar 22, 2018

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes.

Environment

  1. npm ls react-scripts-ts: react-scripts-ts@2.14.0
  2. node -v: v9.7.0
  3. npm -v: 5.7.1
  4. os: macOS 10.13.1

Steps to Reproduce

  1. Install new project as described in README: create-react-app my-app --scripts-version=react-scripts-ts.
  2. Execute npm run test
  3. After cleaning the terminal screen as expected an npm task error is shown and no test is being carried out. Below is shown the issue message.
Determining test suites to run...
--watch is not supported without git/hg, please use --watchAll
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chs-react-ts@0.1.0 test: `react-scripts-ts test --env=jsdom`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chs-react-ts@0.1.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Expected Behavior

No error happen and tests are executed.

Actual Behavior

When running the command described above, the test script is having the mentioned error. This error happens only under a npm context. When running the script directly on terminal only the warning message is shown but still no test is executed.

$ ./node_modules/.bin/react-scripts-ts test --env=jsdom

Determining test suites to run...
--watch is not supported without git/hg, please use --watchAll

This same issue is not happening in base project react-scripts.

After struggling a bit why it is happening I've come across test.js file where is being carried the testing operation. I've just replaced --watch by --watchAll as indicated in the message returned. The next execution was successful.

Intrigued if this change has being done in react-scripts project, I've found the test.js file differs from the current project from line 24. The interesting part is where this option is attached. It is still passing the same --watch and not the --watchAll as the message warns.

So, I don't know if this change I'm pointing out must be the proper fix.

Please have a look when you have time. Thanks.

@nineonine

This comment has been minimized.

nineonine commented Mar 26, 2018

I am experiencing the same issue. However, I just used create-react-app my-app --scripts-version=react-scripts-ts.

changing line 31 in /node_modules/react-scripts-ts/scripts/test.js from

argv.push('--watch');

to

argv.push('--watchAll');

solves the problem.

@imgregduh

This comment has been minimized.

imgregduh commented Apr 1, 2018

What @nineonine suggested does work. I will be waiting for a perm solution

@DorianGrey

This comment has been minimized.

Collaborator

DorianGrey commented Apr 9, 2018

Hm - the CRA solution seems to be to pick up --watchAll in case it is provided, and not adding --watch in that case.
I.e. in case you're not using git or hg, you'd have to replace

"test": "react-scripts-ts test --env=jsdom",

with

"test": "react-scripts-ts test --env=jsdom --watchAll",

in the generated project's package.json.
Surprisingly, this is only included in their next branch, i.e. it won't be release before 2.0. I'll see if we can pre-pick this change.

@patridge

This comment has been minimized.

patridge commented Apr 14, 2018

Until the fix lands in stable, it appears you can also do a quick git init in the target folder to make it happy (as suggested in the error message). Is doing so somehow less ideal than the --watchAll edits recommended above, though?

@DorianGrey

This comment has been minimized.

Collaborator

DorianGrey commented Apr 16, 2018

The change mentioned above was pre-picked and released in 2.15.1 of react-scripts-ts. As this issue only occurs in case you're not using git or hg for version control, you still have to enable this flag manually in your project's package.json as mentioned in #282 (comment).

@DorianGrey DorianGrey closed this Apr 16, 2018

@GaneshRasekar

This comment has been minimized.

GaneshRasekar commented Jul 5, 2018

go to /node_modules/react-scripts-ts/scripts/test.js and
change argv.push('--watch'); on line number 35
to argv.push('--watchAll');
solve for me ;)

Repository owner locked as resolved and limited conversation to collaborators Jul 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.