Skip to content
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

Allow npm audit to ignore dev dependencies #31

Closed
barrynorman opened this issue Oct 25, 2018 · 17 comments
Closed

Allow npm audit to ignore dev dependencies #31

barrynorman opened this issue Oct 25, 2018 · 17 comments

Comments

@barrynorman
Copy link

Add a flag to ignore dev dependencies when running npm audit.
Maybe it could ignore them by default and only check them with a flag.

@khitrenovich
Copy link

Yes, having that would be great.
There was an issue in old repository on that, but nothing actually happened.

@kievsash
Copy link

+1

1 similar comment
@antoniobeltran
Copy link

+1

@kievsash
Copy link

kievsash commented Jan 4, 2019

For now I usually run this command during deploy before running npm audit:
node -e “var fs = require(‘fs’); var content = JSON.parse(fs.readFileSync(‘./package.json’)); delete content.devDependencies; fs.writeFileSync(‘./package.json’, JSON.stringify(content, null, 4))”

@vitorarins
Copy link

vitorarins commented Mar 19, 2019

This has being going for almost a year now I guess.
Any plans on adding this?

@extempl
Copy link

extempl commented Apr 11, 2019

Guys? Anyone from NPM? Your attention is needed here.

@extempl
Copy link

extempl commented Apr 11, 2019

@welwood08 Are you still working on this?

@welwood08
Copy link
Contributor

welwood08 commented Apr 11, 2019

It looks like this might have fallen off my radar due to an unfortunate sequence of events. I believe I was waiting for feedback on my 2 PRs in this repo (#26 is the main one relevant to this issue), and then I think the old npm repo must have been archived at about the same time that Gmail started treating all my Github notifications as spam. By the time I'd noticed it had been quiet, there was a lot to try to catch up on!

I assume my still-open PRs in this repo have suffered bit-rot but I haven't been following recent npm code changes to know how much effort would be needed to revive them. I'm not currently in a position to pick up where I left off anyway so if anyone else wants to tackle it, perhaps using my old PRs as a starting point, feel free to do so.

@TooQ
Copy link

TooQ commented Apr 16, 2019

As a temporary workaround, just remove the devDependencies from your package.json for a moment, and then run npm audit. That way, only your regular dependencies will be checked.

@ghost
Copy link

ghost commented May 10, 2019

yarn implemented group-based audit in v1.16.0. Would be nice to see something similar in npm

@jeemok
Copy link

jeemok commented Jun 30, 2019

for a temporary workaround while waiting for npm to release the ignore feature:

npm install better-npm-audit --save

node node_modules/better-npm-audit audit -i {vulnerability ID}

@nathany
Copy link

nathany commented Oct 3, 2019

npm-audit-helper is another third-party option:

npm audit --json | npm-audit-helper --prod-only

@msegers
Copy link

msegers commented Nov 27, 2019

wowowow I thought this was already in, we still can not do this with npm audit?

@c-vetter
Copy link

Hey everybody,
[TLDR] I think this can be closed.

I wanted to know how to exclude a specific module which does seems to requrie something like @kievsash's hack. I found this issue as well as the related ones in the old repo (npm/npm#20564, npm/npm#20565, npm/npm#20764). I also found some outdated documentation that mentioned a --only=prod CLI parameter.

I tried that out and it did not work as expected (didn't read the documentation too thoroughly 😅), but firstly npm audit --help prints this:

npm audit [--json] [--production]
npm audit fix [--force|--package-lock-only|--dry-run|--production|--only=(dev|prod)]

Some fiddling yielded this:

  • --production flag completely ignores devDependencies
  • --only limits the updates to package.json and package.lock.json

So yeah, while my specific use-case is not handled, I think this issue is resolved by now.

Cheers! 😃

@MNF
Copy link

MNF commented Dec 8, 2019

It was implemented in “Enable production flag for npm audit #202

@c-vetter
Copy link

@barrynorman @isaacs
Can you close this, please?

@isaacs isaacs closed this as completed Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests