警告:node.js检测失败,sbt将使用基于Rhino的Trireme JavaScript引擎

我是Play框架的新手。 请解释下面的警告的含义。

Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js 

我不希望任何会减慢我的应用程序的速度,所以如果我应该将JS Engine更改为node.js,那么请指教,但是我的playframework项目在服务器端使用Java。

你需要安装Node.js,然后告诉sbt / java引擎来使用它。

  brew install node 

编辑.bash_profile并添加:

  export SBT_OPTS="${SBT_OPTS} -Dsbt.jse.engineType=Node -Dsbt.jse.command=$(which node)" 

这消除了我在OSX上的警告

在Ubuntu中

 curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs 

然后像上面那样添加到您的主目录中的.profile

 export SBT_OPTS="${SBT_OPTS} -Dsbt.jse.engineType=Node -Dsbt.jse.command=$(which node)" 

然后

  . ./.profile 

重新加载你的.profile

要使用节点版本pipe理器进行更灵活的安装,请查看以下教程: 如何在ubuntu 14.04服务器上安装节点js

重新构build,关于使用Trireme的警告应该消失。

在Windows中:

  • 安装node.js
  • 进入控制面板 – 系统和安全 – 系统 – 高级系统设置
  • 点击环境variables…
  • 系统variables中searchSBT_OPTS
    • 如果存在,请单击编辑…并连接-Dsbt.jse.engineType=Nodevariables的值
    • 如果不存在,请单击New …并将SBT_OPTS写入variables名称 ,将-Dsbt.jse.engineType=Node variables的值写入
  • 点击确定确定确定
  • 重新启动当前正在运行Play Framework的任何命令提示符(cmd,PowerShell)

作为设置环境variables的替代方法,您可以将此行添加到build.sbt文件中:

 JsEngineKeys.engineType := JsEngineKeys.EngineType.Node 

请参阅: https : //github.com/sbt/sbt-js-engine

在Windows 10中:

https://nodejs.org/en/安装node.js(安装程序会自动将node.js添加到PATH中)

然后加:

 export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node" 

到你的plugins.sbt中

 . ./project/plugins.sbt 

为我工作 – 警告消失了!

编辑:显然plugins.sbt是错误的地方添加

 export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node" 

…虽然加载我的应用程序时,警告消失,但几个小时后重新启动应用程序导致错误:

错误:未find:值导出

如果有人能帮忙,告诉我在哪里出口,我会很高兴。