NPM 'app-root-path' Modul eingebaut um absolute Pfade für .js zu vermeiden
This commit is contained in:
parent
67e5d20854
commit
2897a9c0a3
3
.gitignore
vendored
3
.gitignore
vendored
@ -104,7 +104,6 @@ dist
|
|||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
# vuepress v2.x temp and cache directory
|
||||||
.temp
|
.temp
|
||||||
.cache
|
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
# Docusaurus cache and generated files
|
||||||
.docusaurus
|
.docusaurus
|
||||||
@ -132,3 +131,5 @@ dist
|
|||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
/.idea/git_toolbox_blame.xml
|
/.idea/git_toolbox_blame.xml
|
||||||
|
.package.json
|
||||||
|
.package-lock.json
|
||||||
@ -1,5 +1,7 @@
|
|||||||
const mysql = require('mysql2');
|
const mysql = require('mysql2');
|
||||||
require('dotenv').config({path: 'C:/Daten/Webshop/process.env'});
|
require('dotenv').config({path: 'C:/Daten/Webshop/process.env'});
|
||||||
|
//to-do: '.env' Dateien aus anderen Directories aufrufen ohne absoluten Pfad
|
||||||
|
// require("dotenv").config({path:'C:/Daten/Webshop/process.env'})
|
||||||
|
|
||||||
const connection = mysql.createConnection({
|
const connection = mysql.createConnection({
|
||||||
host : process.env.DB_HOST,
|
host : process.env.DB_HOST,
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
require('mysql2')
|
require('mysql2')
|
||||||
var connection = require('./db-connect')
|
|
||||||
connection.query("SELECT * FROM webshop.user WHERE ID = 15", function (err, result) {
|
let appRoot = require('app-root-path')
|
||||||
|
let dbConnect = require(appRoot + '/scripts/modules/db-connect.js')
|
||||||
|
|
||||||
|
dbConnect.query("SELECT * FROM webshop.user WHERE ID = 0", function (err, result) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(result)
|
console.log(result)
|
||||||
})
|
})
|
||||||
connection.end()
|
dbConnect.end()
|
||||||
|
|
||||||
// require("dotenv").config({path:'C:/Daten/Webshop/process.env'})
|
|
||||||
Loading…
x
Reference in New Issue
Block a user