Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot find module 'jsdom' #2642

Closed
japgolly opened this issue Nov 5, 2016 · 6 comments
Closed

Cannot find module 'jsdom' #2642

japgolly opened this issue Nov 5, 2016 · 6 comments
Labels
question This is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.

Comments

@japgolly
Copy link
Contributor

japgolly commented Nov 5, 2016

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?

@ochrons
Copy link

ochrons commented Nov 5, 2016

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

@japgolly
Copy link
Contributor Author

@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".

@japgolly
Copy link
Contributor Author

Same issue as #2378?

@ochrons
Copy link

ochrons commented Jan 31, 2017

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?

@japgolly
Copy link
Contributor Author

japgolly commented Feb 1, 2017

Thanks @ochrons. I added set parallelExecution in ThisBuild := false to Travis and it seems to have fixed it.

@japgolly japgolly closed this as completed Feb 1, 2017
@sjrd sjrd added the question This is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter. label Mar 18, 2017
benhutchison added a commit to benhutchison/scalajs-websocket that referenced this issue Nov 6, 2018
@nafg
Copy link

nafg commented Nov 25, 2022

Is it possible to get it to use a node_modules in a different place (like in target/out)?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question This is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.
Projects
None yet
Development

No branches or pull requests

4 participants