Cannot find module 'jsdom'
japgolly opened this issue · 6 comments
Hi. Using 0.6.13 I decided to try out nodejs & jsdom.
The only Scala.JS test setting I set is:
requiresDOM := true
I installed jsdom globally, see here:
> npm list -g jsdom
/usr/lib
└── jsdom@9.8.3
However when I run tests I get:
> sbt
[info] Loading global plugins from /home/golly/.sbt/0.13/plugins
[info] Loading project definition from /home/golly/projects/scalajs-react/project
[info] Set current project to root (in build file:/home/golly/projects/scalajs-react/)
> test
[info] Fast optimizing /home/golly/projects/scalajs-react/test/target/scala-2.11/test-test-fastopt.js
[error] module.js:474
[error] throw err;
[error] ^
[error]
[error] Error: Cannot find module 'jsdom'
[error] at Function.Module._resolveFilename (module.js:472:15)
[error] at Function.Module._load (module.js:420:25)
[error] at Module.require (module.js:500:17)
[error] at require (internal/module.js:20:19)
[error] at [stdin]:35:17
[error] at [stdin]:93:3
[error] at ContextifyScript.Script.runInThisContext (vm.js:25:33)
[error] at Object.exports.runInThisContext (vm.js:77:17)
[error] at Object.<anonymous> ([stdin]-wrapper:6:22)
[error] at Module._compile (module.js:573:32)
[trace] Stack trace suppressed: run last test/test:loadedTestFrameworks for the full output.
[error] (test/test:loadedTestFrameworks) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1
[error] Total time: 13 s, completed 05/11/2016 7:13:44 PM
Versions are:
> node --version
v7.0.0
> npm --version
3.10.9
Do you see something I'm missing?
It doesn't work when installed globally (for some reason), so you need to install it per project. Remember to add node_modules
to .gitignore :)
Also in Travis the default version of Node is too old so you need to add to your .travis.yml
this:
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
- npm install jsdom
@ochrons Are you able to have a quick look at my .travis.yml? I can't get scalajs-react with jsdom in Travis. It keeps saying "Node.js isn't connected".
The node/jsdom setup works with spa tutorial (https://travis-ci.org/ochrons/scalajs-spa-tutorial/builds/184434514) but perhaps in your setup there are too many concurrent tests and that causes issues? Can you try making tests run in serial on Travis?
Thanks @ochrons. I added set parallelExecution in ThisBuild := false
to Travis and it seems to have fixed it.
Is it possible to get it to use a node_modules in a different place (like in target
/out
)?