2

I've created new play framework app using a angular-seed-play-java template. So now I'm trying to install Babel as a transpiler.

Following these instructions I've added sbt-babeljs to my plugins.sbt
https://github.com/stonexx/sbt-babeljs .

Then I want to install bubel-core locally. I got a webjar from the http://www.webjars.org/ and inserted the following line into my build.sbt .

"org.webjars.npm" % "babel-core" % "6.11.4"

I'm getting unresolved dependency error:

[error] (*:update) sbt.ResolveException: unresolved dependency: org.webjars.npm#babel-types;[6.9.1,7): not found  
[error] unresolved dependency: org.webjars.npm#babel-template;[6.9.0,7): not found
[error] unresolved dependency: org.webjars.npm#babel-traverse;[6.11.4,7): not found

There is no required version of babel-types at http://www.webjars.org/ . And I get similar problems with some other webjars. I constantly get unresolved dependency errors. How I supposed to solve those?

Thanks in advance.

Vahan
  • 169
  • 3
  • 12

1 Answers1

2

Hope that you have checked the SBTDependency Documentation for play framework in the official site. Check SBTDocumentation for Resolvers too.

I would recommend you try this 1st before trying all below different solutions that I found online.

Download the buble-core locally as you mentioned and place it in the local .m2 folder to make it available as a local repository.

Let sbt get to know the location of the downloaded webjar by setting it through resolvers like below - sbt can search your local Maven repository if you add it as a repository:

resolvers += (
    "Local Maven Repository" at "file:///"+Path.userHome.absolutePath+"/.m2/repository"
)

Hope this should work in your situation, if this didn't work try below solution I found online

Try1

  1. Install babel-core globally with npm:

npm install babel-core -g

  1. Then add environment variable called 'NODE_PATH' with value '%AppData%\npm\node_modules'

Try2

Create package.json file in project root and write the below.

{
  "devDependencies": {
    "babel-core": "^6.2.4"
  }
}

then Run "babel" task on sbt console.

Try3

Create [node_modules] directory and download babel-core automatically. (You don't have to [babel-core] install globally and set environment.)

Source for all these Try-Solutions is this.

Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
  • @Vahan can I get an update with this answer whether it helped you or not, if you find a solution on your own please do share it would help others too thanks – Keshan Nageswaran Aug 20 '16 at 10:47
  • Hi @kesh, Sure I'll let you know. Though I didn't want to install the package globally but it didn't work neither. But I've decided not to spend time on the global installation issue. Now I'm reading sbt book. With Maven it was much easier but with Sbt it seems that googling is not enough. I think I will get some result within 2-3 days. – Vahan Aug 22 '16 at 14:28
  • I've added addSbtPlugin("io.teamscala.sbt" % "sbt-babeljs" % "1.0.3") to my plugins.sbt file. and removed the reference from build.sbt. Added package.json. now I don't get any error. I just don't know how to add the task itself, so my js files will be compiled. It is so messy... – Vahan Aug 25 '16 at 02:58