简体   繁体   中英

Requiring module with karma not working

I create a dev Javascript environment using TDD by using node, jake, karma, chai and browserify. Everything works fine, tests run green. Now I want to use Raphael to draw SVGs. I installed raphael npm install raphael to my local node environment (not globally). Requiring

var raphael = require("node-raphael")

Whenever I require it in my app.js file, it throws an error:

Uncaught Error: Could not find module 'raphael' from '../Project/src/javascript/app.js'

Just for testing I required it in my jakefile which is in my Project directory. There, requiring works fine. But using the Raphael functions also does not work.

node modules are also placed in the Project dir. "Project/node-modules/raphael"

I haven't used raphael , but from looking at npmjs.com there are two different modules: raphael and node-raphael . You have installed raphael , but you are requiring node-raphael . So, you either need to install node-raphael :

npm install node-raphael

or require raphael in your code:

var raphael = require("raphael")

See https://www.npmjs.com/package/raphael and https://www.npmjs.com/package/node-raphael .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM