Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

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

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

Comments

@emoriarty
Copy link

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: [email protected]
  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! [email protected] test: `react-scripts-ts test --env=jsdom`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
Copy link

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
Copy link

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

@DorianGrey
Copy link
Collaborator

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
Copy link

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
Copy link
Collaborator

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).

@GaneshRasekar
Copy link

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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants