Reputation: 21
I am a novice with Nodejs, I try to integrate admin LTE templates into my node project. but I can't succeed.
They could correct what I'm doing wrong in the configuration
package.json
{
"name": "node-admin",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"admin-lte": "^3.0.4",
"express": "^4.17.1",
"jquery": "^3.5.1",
"morgan": "^1.10.0"
}
}
index.js
const express = require('express');
let app = express();
const path = require('path');
const morgan = require('morgan');
app.use(morgan('dev'));
app.use('/css', express.static(path.join(__dirname, '/node_modules/admin-lte/dist')));
app.use('/js', express.static(path.join(__dirname, '/node_modules/admin-lte/dist')));
app.use('/js', express.static(path.join(__dirname, '/node_modules/jquery/dist')));
app.use('/img', express.static(path.join(__dirname, '/node_modules/admin-lte/dist')));
app.set('admin-lte', './node_modules');
app.use('/admin', express.static('./node_modules/admin-lte'));
app.listen(3001, () => {
console.log("Listenning on PORT 3001 >> http://localhost:3001");
})
admin-lte folder in node_modules
proyecto node
Upvotes: 0
Views: 1632
Reputation: 11
Dears your pointing to
app.use('/admin', express.static('./node_modules/admin-lte'));
if type http://localhost:3001/admin/ you will get adminlte interface, you need to do that or change previous line to:
app.use('/', express.static('./node_modules/admin-lte'));
Upvotes: 1