vytaute
vytaute

Reputation: 1480

Cant resolve fs, net, tls after mysql installation

I have react-boilerplate application. I want to start using database so I installed:

npm install mysql   
npm install mysqljs/mysql

As shown in mysql webpage: https://www.npmjs.com/package/mysql

Now I get errors when I go to localhost in a browser:

 Can't resolve 'fs' in '....node_modules\mysql\lib\protocol\sequences'
 Can't resolve 'net' in '....node_modules\mysql\lib'
 Can't resolve 'tls' in '....node_modules\mysql\lib'

I am using redux-saga combination. I figured out that I get the error when I write:

const mysql = require('mysql');

in saga.js file

How can I fix these errors?

Upvotes: 1

Views: 1114

Answers (1)

AKX
AKX

Reputation: 169338

You can't use a MySQL client library within a browser app.

The errors you're seeing is the client library attempting to require() Node.js standard libraries for file system, network and encryption (TLS) access, which don't exist in the browser.

Upvotes: 0

Related Questions