question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include only specific node_modules

See original GitHub issue

Please describe your issue: Let’s assume that I want to exclude these files from packaging:

  • npm-debug
  • gulpfile.js
  • .vscode

So setting --ignore option like this:

--ignore='npm-debug|gulpfile\.js|\.vscode'

It’s working. But how to I make regex that exclude only specific node_modules with above regex? I tried:

--ignode='npm-debug|gulpfile\.js|\.vscode|^((?!node_modules/mqtt).)$'  // NOT WORKING

but it won’t worked. I know my regex was wrong, but I don’t know how should I do now. Literally, I’m stucked now. Is there a something another option to include specific files from --ignore option? Else, how do I resolve this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
MarshallOfSoundcommented, Jan 31, 2017

@rico345100 If you don’t want a node_module to be included in production, just set it as a devDepednency and it will be pruned automatically

1reaction
MarshallOfSoundcommented, Jan 31, 2017

@rico345100

Untested but this regexp should do what you want

--ignore="^\/(.vscode|gulpfile.js|userdata.json|npm-debug.log|my-app-darwin-x64)"

Basically add things that you want to ignore inside those brackets. The key bit to that regexp is ^\/ which forces the match to be at the start of the path 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to include only specific module in webpack without ...
I'm working with a monorepo node.js project with the following structure: rootDir packageA packageB packageC. I want to produce a bundle of ...
Read more >
How To Use Node.js Modules with npm and package.json
The node_modules folder contains every installed dependency for your project. In most cases, you should not commit this folder into your version ...
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
Within a "type": "module" package, Node.js can be instructed to interpret a particular file as CommonJS by naming it with a .cjs extension...
Read more >
package.json - npm Docs
Therefore, the name can't contain any non-URL-safe characters. Some tips: Don't use the same name as a core Node module. Don't put "js"...
Read more >
Using Node.js Modules with Azure applications - Microsoft Learn
Each module within the node_modules directory maintains its own directory that contains any modules that it depends on, and this behavior ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found