我在 Windows 上開發了一個 NodeJs(v10.19.0) 服務器。我現在需要將它轉移到運行 Ubuntu 20.04 的 linux 服務器上。當我嘗試啟動服務器時,“=”上出現語法錯誤。
這是完整的錯誤:
/puppeteer/scraping-bot.js:6
static websiteRegex = /^(https?\:\/\/)?([\da-z\.-] )\.([a-z\.]{2,6})(\/[\w\W]*)*$/gm
^
SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/routes/scraping.js:1:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
[nodemon] app crashed - waiting for file changes before starting...
這是輸出錯誤的代碼:
class ScrapingBot {
static websiteRegex = /^(https?\:\/\/)?([\da-z\.-] )\.([a-z\.]{2,6})(\/[\w\W]*)*$/gm
static phoneRegex = /\ ?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g;
static addressRegex = /(([a-zA-Z-ééèèààùùa?êê??????????üü????'.]*\s)\d*(\s[a-zA-Z-ééèèààùùa?êê??????????üü????']*)*,)*\d*(\s[a-zA-Z-ééèèààùùa?êê??????????üü????']*) ,\s([\d]{5})\s[a-zA-Z-ééèèààùùa?êê??????????üü????'] /
...
}
如果有幫助,我會用 nano 設定 Git...
我已經嘗試替換“=”。
uj5u.com熱心網友回復:
正如您在此處看到的,從節點 10 開始不支持靜態類欄位 -> https://node.green/#ES2022-features-static-class-fields
編輯:@jonrsharpe 也回答了這個問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/492913.html
