Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

350
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda