我剛開始學習express,之前接觸過前端框架可以透過CLI 去打包成dist資料夾,deploy到IIS上,想要請問express 的project 也可以做到嗎?
我透過 express --view=ejs myapp
建立了一個 express 的 project 並使用 webpack進行打包,但是我一直得到錯誤
const path = require('path');
const clientConfig = {
resolve: {
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
"crypto-browserify": require.resolve('crypto-browserify'),
}
},
entry: {
'index': './app.js'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js'
}
}
module.exports = [clientConfig];
{
"name": "myapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"webpack": "webpack"
},
"browser": {
"crypto": false
},
"dependencies": {
"cookie-parser": "~1.4.4",
"crypto-browserify": "^3.12.0",
"debug": "~2.6.9",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"morgan": "~1.9.1",
"path": "^0.12.7",
"twig": "~0.10.3"
},
"main": "app.js",
"devDependencies": {
"webpack": "^5.26.3",
"webpack-cli": "^4.5.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
前端框架執行的位置是在瀏覽器上,iis只是作為內容派送的伺服器,所以提供的是靜態檔案,而node.js是在後端執行的服務,所以無法只是打包成.js檔案來部署。
看你的提問應該是想要在iis上運作node.js的專案,伺服器端還是需要安裝node.js,並透過iisnode套件好讓iis具備執行node.js的能力,google一下找到不少文章,提供一篇給你
http://andy51002000.blogspot.com/2017/06/iisnodejs.html