Sty*_*war 6 javascript deployment node.js
所以我已经部署了我的网站 Nodejs + MySQL,但问题是我收到错误
503 Service Unavailable The server is temporarily busy, try again later!
所以我看到了一个线程:相反,将index.js的需求更改为所有CommonJS模块中都可用的动态导入(),我按照该线程并安装了
npm i node-fetch@2.6.1
之后,我也返回到我的setup nodejs并停止该过程,然后npm install再次收到相同的错误,当我检查我的时,stderr.log我收到此错误
/usr/local/lsws/fcgi-bin/lsnode.js:48 var app = require(startupFile); ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/ppsconl2/nodejs/index.js from /usr/local/lsws/fcgi-bin/lsnode.js not supported.
Instead change the require of index.js in /usr/local/lsws/fcgi-bin/lsnode.js to a dynamic import() which is available in all CommonJS modules.
at startApplication (/usr/local/lsws/fcgi-bin/lsnode.js:48:15)
at Object.<anonymous> (/usr/local/lsws/fcgi-bin/lsnode.js:16:1) {
code: 'ERR_REQUIRE_ESM'
}
Run Code Online (Sandbox Code Playgroud)
这是我的 package.json
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.2",
"mysql2": "^3.2.0",
"nodemon": "^2.0.21"
}
}
Run Code Online (Sandbox Code Playgroud)
主机的节点jsv18.9.1在我的电脑上是v18.14.1