How to Remove Flow Issues in Node Modules?

BlueEast
BlueEast
Published in
2 min readOct 5, 2018
Removing Flow Issues in Node Module

During the run flow command, flow issues are commonly faced in node modules. An error similar to the following may occur:-

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! projectabc@1.0.0 flow: `flow`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the projectabc@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/developer123/.npm/_logs/2017–10–31T06_14_39_009Z-debug.log

Step-by-Step Guide to Remove Flow Issues:

Following steps are involved to remove flow issues:

  1. Create .flowconfig in project root folder in case if it is not already created.
  2. Open .flowconfig file and write the below stated code.
[ignore].*/node_modules/*[include][libs][lints][options]

Applying this code will ignore flow errors from the node modules.

After code application, run npm run flow. At this point, it will show new errors similar to what you will receive in the scenario if you have imported any node module in your project.

Here, you’ll encounter this type of an error:-

require modulesLaunching Flow server for /var/www/projectabc/projectabc-api-server
Spawned flow server (pid=6247)
Logs will go to /tmp/flow/zSvarzSwwwzSprojectabczSprojectabc-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! projectabc flow: `flow`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the projectabc@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/developer123/.npm/_logs/2017-10-31T06_16_25_402Z-debug.log

To remove these errors, follow the these steps.

Here’s What You Do Next:-

  1. Open the terminal and access the root folder of project.
  2. Run the following command:-
sudo npm install -g flow-typedflow-typed create-stub mocha@x.x.x

Here, mocha is the name of the node module. You would have to write your own require module’s name one by one & you’ll be sorted.

--

--