I am trying to figure out what I have done wrong with this Javascript code. I have tried googling the error with no avail.
The following is there error I get.
Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\Users\calon\source\repos\CAL0NZ0\Treasure-Box-Azure\async_hooks' required by C:\Users\calon\source\repos\CAL0NZ0\Treasure-Box-Azure\node_modules\on-finished\index.js
And here is the Javascript code used.
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const { CosmosClient } = require('@azure/cosmos');
const config = require('./config');
const endpoint = config.endpoint;
const key = config.key;
const client = new CosmosClient({ endpoint, key });
const database = client.database('treasure_box');
const container = database.container('logins');
const app = express();
let initialPath = path.join(__dirname, 'treasure-box-azure');
app.use(bodyParser.json());
app.use(express.static(initialPath));
app.get('/', (req, res) => {
res.sendFile(path.join(initialPath, 'index.html'));
});
app.get('/login', (req, res) => {
res.sendFile(path.join(initialPath, 'login.html'));
});
app.get('/register', (req, res) => {
res.sendFile(path.join(initialPath, 'register.html'));
});
app.post('/register-user', (req, res) => {
const { name, email, password } = req.body;
if (!name.length || !email.length || !password.length) {
res.json('Fill out all field');
} else {
container
.insert({
name: name,
email: email,
password: password,
})
.returning(['name', 'email'])
.then((data) => {
res.json(data[0]);
})
.catch((err) => {
if (err.detail.includes('Already Exists')) {
res.json('Email already exists');
}
});
}
});
app.post('/login-user', (req, res) => {
const { email, password } = req.body;
container
.select('name', 'email')
.where({
email: email,
password: password,
})
.then((data) => {
if (data.length) {
res.json(data[0]);
} else {
res.json('Email or password is incorrect');
}
});
});
app.listen(403, (req, res) => {
console.log('listening on 403');
});
I use the following command to allow my JS files to run on the browser. I don't have any issues with the other files. Just this particular one.
"browserify ./application/staging/index-s.js > ./application/deploy/index.js -t babelify --plugin tinyify"