Craftsman at work

I'm Artur Karbone, coding software architect and independent IT consultant and this is my blog about craftsmanship, architecture, distributive systems, management and much more.

.NET Core: Watch out, Dude. node_modules Can Break Your Backend Build

Just faced an unexpected problem in my ASP.NET Core project. Here is the deal, I've added CLI tool for Angular2 support exactly to the web project. I know it's a good practice to separate frontend and backend, but in my view, it's acceptable to deliver them as a single unit for simplicity purposes sometimes.

The problem arose right after installing CLI tool for Angular2. I kept getting the following error during backend compilation:

alt

Wow, the fact that that node_modules can contain server-side code was a surprise for me, frankly. Well going into node_modules to compile something out there was a behavior I didn't expect, to be honest. In my particular case the Selenium web driver was causing the issue:

alt

I resolved the issue by letting the compiler know that I want to exclude node_modules folder from the pipeline, by tweaking buildOptions/compile section in project.json file. Like this:

 "buildOptions": {
    "emitEntryPoint": true,
    "compile": {
      "exclude": ["node_modules"]
    }
  }
comments powered by Disqus