Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
Node js - Importing mssql module for use in an Angular 2 project errors : " Can't resolve 'dns' " and " Can't resolve 'dgram' "

I have rudimentary experience in both Angular 2 and NodeJS development. I apologize if this question is too simple of nature.

My goal is to create a web interface which connects to a SQL Server database. This app would enable the user to easily send queries to and receive results from the connected database from the app.

Searching for solutions, I decided to import mssql module into my mssql-connection.service.ts after installing via npm. I was planning to use it in the service either by using dependency injection or its regular syntax. However, I am experiencing error while compiling in each of those situations.

First, in trying to use the DI method by writing import { MSSQL } from 'mssql'; I get two duplicate error messages node_modules/@types/mssql/index"' has no exported member 'MSSQL'.

Second, in my attempt to remedy the situation as a response, I write import 'mssql';. Then I get a total of three error messages: I get two duplicate error messages Can't resolve 'dns' in '...\node_modules\tedious\lib' and an error message Can't resolve 'dgram' in '...\node_modules\tedious\lib' I have also tried using const sql = require('mssql'); but this would give me Cannot find name 'require'. error message, preceded by the previous error messages.

I am stumped and would like to know why this is happening! I would like to be able to use external modules freely. I have also tried npm install @types/mssql but to no avail. My node version is v6.9.5, and am using Angular 4.0.0. Please help!

Thank you in advance.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I don't really think what you're trying to achieve here is makes any sense. Don't you think it would be an anti-pattern to use this in your Angular App? How exactly are you supposed to distribute this App and make it secure as well?

I would suggest you use mssql, in your NodeJS project. You can expose APIs from there that you'll hit from your Angular App. That's what is the purpose of a client after all.

Doing this will make your code more manageable, maintainable, and loosely coupled.

Hope this makes sense.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!