B
B
bpGusar2019-08-21 11:59:51
Node.js
bpGusar, 2019-08-21 11:59:51

How to run npm view inside express route and get data as JSON?

Sobsno how to run it, I understood, I do it like this

exec(`npm view ${package_name}`, (err, stdout, stderr) => {
    res.send(stdout);
  });

But in response to me comes such a crap
[4m[1m[32mcookie[[email protected][32m0.4.0[39m[22m[24m | [32mMIT[39m | deps: [32mnone[39m | versions: [33m21[39m HTTP server cookie parsing and serialization [36m https://github.com/jshttp/cookie#readme[39m keywords: [33mcookie[39m, [33mcookies[39m dist .tarball: [36m https:// registry.npmjs.org/cookie / - / a cookie-0.4.0.t ... .shasum: [33mbeb437e7022b3b6d49019d088665303ebe9c14ba [39m .integrity: [33msha512- Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg + / + JQX 1Om94 / W6ZaPDOUbnjOt / 99w66zk l1Xg == + [39m. unpackedSize: [33m17.9[39m kB maintainers: - [33mdougwilson[39m <[[email protected][39m> dist-tags: [1m[32mlatest[39m[22m: 0.4.0 published [33m3 months ago[39m by [33mdougwilson[39m] <[[email protected][39m>

How to get data in JSON format?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Alexander, 2019-08-21
@bpGusar

Good afternoon!
To get the result of a command as JSON, you need to complete the command with a flag, for example:
npm view --json express

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question