Browserify 또는 Webpack과 같은 패키지 소프트웨어를 사용하지 않고도 nodej에있는 간단한 서버를 사용할 수 있습니다.nodejs node_modules 디렉토리에서 프론트 엔드에 액세스 할 수있는 방법은 무엇입니까?
var express = require('express');
var bodyParser = require('body-parser');
var request = require('request');
var app = express();
app.use(bodyParser());
app.use(express.static('public'));
app.use(express.static('node_modules'));
app.post('/api/searchjob', function (req, res) {
res.json({data: "hello"});
});
app.get('/', function(req,res) {
res.sendfile('public/index.html');
});
app.get('/*', function(req, res){
res.redirect('/');
})
app.listen(process.env.PORT || 3000, function() {
console.log('Example app listening on port 3000!')
});
프런트 엔드가 일부 node_modules 패키지에 액세스 할 수있게하려면 어떻게해야합니까? 내 index.html 파일은 "공공"디렉토리에 폴더 구조는 다음과 같다 :
├── README.md
├── index.js
├── node_modules
├── package.json
├── public
└── yarn.lock
I 시도 단순히 index.html을에서 스크립트 태그를 추가하는 듯했지만 작동하지 않습니다 <script src="../node_modules/vue2-google-maps/dist/vue-google-maps.js"></script
>