Load an npm module through dev console


I like to test out code snippets in the dev tools console as I’m working on plugins.

How can I properly require modules into the console?


I’m a bit surprised there has been no answer to this as it’s a useful idea.


fs = require('fs') works. Just keep in mind that the JavaScript console in the Developer Tools is a JavaScript console, not a CoffeeScript one.


Thanks @leedohm, but I want to require modules in my package, not just the core node modules.

But if I require("module") that is in my package.json (and installed) I get an error Cannot find module 'module'


Since the console isn’t executing code from the same directory as the package, you probably need to use the full path. What about require(atom.packages.resolvePackagePath(<name>) + "node_modules/<module>")?