我正在尝试在node_modules中使用缩小的文件,并且当应用程序在线时,文件无法正常工作...
我正在像这样链接css文件:
<link href="../node_modules/@glidejs/glide/dist/css/glide.core.min.css" rel="stylesheet" type="text/css">
</head>
在底部这样的js:
<script src="../node_modules/@glidejs/glide/dist/glide.min.js"></script>
这是我的package.json文件:
{
"name": "testing",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node src/index.js"
},
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"@glidejs/glide": "^3.3.0",
"express": "^4.17.1",
"sal.js": "^0.6.1"
}
}
在我的src / index.js文件中,我有这个:
const path = require('path')
const http = require('http')
const express = require('express')
const app = express()
const server = http.createServer(app)
const port = process.env.PORT || 3000
const publicDirectoryPath = path.join(__dirname, '../public')
app.use(express.static(publicDirectoryPath))
server.listen(port, () => {
console.log(`Server is up on port ${port}`)
})
我的公用文件夹已经在线,并且可以很好地读取html,css和img文件夹。问题是node_modules中的文件不起作用...
node_modules已经托管在heroku上。当我链接到我的html标签中的node_modules文件时,我使用了错误的“ ../”?请帮忙!!!