[英]Use of const in strict mode : Azure Web App
Application has thrown an uncaught exception and is terminated: SyntaxError: Use of const in strict mode.
at Module._compile (module.js:434:25)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (D:\home\site\wwwroot\node_modules\mongoose\index.js:7:18)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
每次創建Azure Web App項目並發布Express App都會引發錯誤。 我嘗試使用Azure Express以及Blank nodeJs App來做到這一點
看來是由Azure上的無效節點版本引起的。 轉到Azure門戶(您的Web應用程序-應用程序設置),檢查WEBSITE_NODE_DEFAULT_VERSION
。
一旦我們指定了Azure上不可用的版本,就會使用一個相當舊的版本0.10.40,默認情況下未啟用const
,這樣我們遇到了SyntaxError: Use of const in strict mode
。 有關更多詳細信息,請參見相關線程 。
我們可以使用10.6.0、8.11.1等。請訪問https://<yourwebappname>.scm.azurewebsites.net/api/diagnostics/runtime
以查看所有可用版本。
Clinkz警告
在某些情況下,上述解決方案可能不起作用。 這可能是因為您的項目包含文件iisnode.yml
。 如果該文件存在,它將覆蓋應用程序設置環境變量。 該文件的內容應如下:
nodeProcessCommandLine: "%SystemDrive%\Program Files (x86)\nodejs\0.10.4\node.exe"
此處指定的節點版本優先。 要修復它,只需更新版本,然后進行部署:
nodeProcessCommandLine: "%SystemDrive%\Program Files (x86)\nodejs\8.9.4\node.exe"
參考這個 。
最后 ,優先級為:iisnode.yml> package.json(engine)>應用程序設置。 建議您設置應用程序,因為它很容易在門戶網站上檢查和修改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.