我正尝试部署到我的AWS环境,并且在nodejs.log
下遇到此错误
/var/app/current/node_modules/opn/index.js:11
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/app/current/node_modules/live-server/index.js:11:9)
npm ERR! Linux 4.14.47-56.37.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/npm" "start"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angularspree@0.0.1 start: `cd dist && ../node_modules/live-server/live-server.js --port=8081 --host=localhost --entry-file=/index.html`
npm ERR! Exit status 1
npm ERR! Failed at the angularspree@0.0.1 start script 'cd dist && ../node_modules/live-server/live-server.js --port=8081 --host=localhost >--entry-file=/index.html'.
我尝试重新部署,但问题仍然存在。
AWS支持建议恢复到nodejs v6.14.3,但不再可用
对于提到的index.js,这是代码的一部分,并且该行被认为是错误所在的行:
var fs = require('fs'),
connect = require('connect'),
serveIndex = require('serve-index'),
logger = require('morgan'),
WebSocket = require('faye-websocket'),
path = require('path'),
url = require('url'),
http = require('http'),
send = require('send'),
open = require('opn'),<<<< line 9
es = require("event-stream"),
os = require('os'),
chokidar = require('chokidar');
OPN已被弃用。所以我安装了OPEN。但是open = require('opn')尚未更新。
有人对如何解决此问题有任何想法吗?
答案 0 :(得分:0)
这似乎是因为opn(现已打开)引入了一些仅在Node 8.3.0和更高版本中存在的新功能...使用较新的Node解决了此问题。
答案 1 :(得分:0)
将您的节点版本更改为 8.3 或更高版本。你可以使用 n 来做到这一点
npm install -g n
n 8.3.0
npm install live-server
现在应该安装实时服务器。要确认运行以下命令以获取已安装的版本号
live-server -v