How to remove flow issues in node modules?

During run flow command, we were facing flow issues in node modules. Error is something like this:

Errors
Error: node_modules/bcryptjs/src/bower.json:4
4: “version”: /*?== VERSION */,
^ Unexpected token ,
Error: node_modules/strong-globalize/test/fixtures/extract013/intl/en/messages.json:2
2: “msgPredefined”: “This is a predefined message in a broken json
^ Unexpected token ILLEGAL
Found 42 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! dukaan@1.0.0 flow: `flow`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the dukaan@1.0.0 flow script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ghazal/.npm/_logs/2017–10–31T06_14_39_009Z-debug.

Step-by-step guide:

Following steps involved to remove flow issues:

  1. Create .flowconfig in project root folder, if it is not already created.
  2. Open .flowconfig file and write the following code.
[ignore]
.*/node_modules/*

[include]

[libs]

[lints]

[options]

This will ignore the flow errors from node modules.

After this run npm run flow , Now it will give new errors if you have import / require any node module in your project. Error is like below:

Launching Flow server for /var/www/dukaan/dukaan-api-server
Spawned flow server (pid=6247)
Logs will go to /tmp/flow/zSvarzSwwwzSdukaanzSdukaan-api-server.log
Error: test/attribute.test.js:4
 4: const chai = require('chai');
 ^^^^^^ chai. Required module not found

Error: test/attribute.test.js:5
 5: const mocha = require('mocha');
 ^^^^^^^ mocha. Required module not found

Error: test/attribute.test.js:6
 6: const chaiHttp = require('chai-http');
 ^^^^^^^^^^^ chai-http. Required module not found

Found 24 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! dukaan@1.0.0 flow: `flow`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the dukaan@1.0.0 flow script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ghazal/.npm/_logs/2017-10-31T06_16_25_402Z-debug.log

To remove these errors, follow the following steps.
Step-by-step guide:

Following steps involved to remove require modules flow issues:

  1. Open terminal and go to root folder of project.
  2. Run the commands below
sudo npm install -g flow-typed
flow-typed create-stub mocha@x.x.x

Here mocha is the node module name. You have to write your own require modules name one by one.

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site!