Node not requiring *.coffee files - node.js

According, to https://stackoverflow.com/a/4769079/347915, I should be able to require a .coffee file from a .js file:
$ echo 'console.log "works"' > module.coffee
$ echo '
> require("coffee-script")
> require("./module")
> ' > test.js
$ node test.js
works
However, when I do that, I get this message when running test.js:
module.js:340
throw err;
^
Error: Cannot find module './module'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/jose/Desktop/pedo/test.js:2:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
I'm using Node 0.10.25 installed using NVM. Also using CoffeeScript 1.7.1 installed using NPM 1.3.24.

Since Coffeescript 1.7.0, the required library changed. Now you have to use:
require('coffee-script/register');
See the changelog: http://coffeescript.org/

Related

Yeoman, ran yo webapp, grunt throwing error

I ran 'yo webapp' and am now trying to run grunt serve and get the error that is below. Has anyone seen this error before?
grunt serve
module.js:340
throw err;
^
Error: Cannot find module 'findup-sync'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/william/wdi/pixelect_project/pixelect_client_server/node_modules/grunt/lib/grunt/file.js:24:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
You are probably forgetting about installing the dependencies. Try to install the dependencies using bower before running grunt.
Try to run this:bower install.

Error: cannot find module './lib/middleware'

I am attempting to run the demo for the mobwrite node.js package. First I installed the mobwrite package (npm install mobwrite) and then entered the following command:
node -e "require('mobwrite').quickserve()"
A demo server should start, but the following error is thrown:
module.js:340
throw err;
^
Error: Cannot find module './lib/middleware'
at Function.Module._resolveFilename (module.js:388:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (PATH_TO_MODULES\mobwrite.js:2:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at [eval]:1:1
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compie (module.js:456:26)
at evalScript (node.js:532:25)
at startup (node.js:80:7)
at node.js:901:3
This originates from the mobwrite.js file, in which the package needs to include a middleware file (middleware.coffee) which is stored in a lib folder:
require("coffee-script")
middleware = require("./lib/middleware")
module.exports = middleware
I have looked at the answers to similar posts on SO, but nothing has solved my problem so far. How can I overcome this error?
You could try manually compiling the coffeescript files to javascript: npm install -g coffee-script && coffee -c node_modules/mobwrite/lib/middleware.coffee && coffee -c node_modules/mobwrite/lib/daemon.coffee. Then retry your command.

'The specified module could not be found' error when using 'scrypt' module in node.js

I'm trying to use 'scrypt' module. The problem is that when I try to run my nodejs application (node app.js), I get this error:
C:\Users\A\Documents\B\C>node app.js
module.js:356
Module._extensions[extension](this, filename);
^
Error: The specified module could not be found.
C:\Users\A\Documents\B\C\node_modules\scrypt\build\Release\scry
pt.node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\A\Documents\B\C\node_module
s\scrypt\index.js:1:76)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I installed 'scrypt' module with this line:
npm install scrypt -msvs_version=2012
the -msvs_version is taken from this answer
You should have a look at this node-scrypt issue.
According to what is said there, you should be able to solve your problem by
either installing OpenSSL for Windows
or installing and building with Visual Studio 2010

Cannot run express-spdy app using NodeJS

I'm not able to run NodeJS Express-Spdy examples downloaded from GitHub.
I'm getting the below error:
C:\Program Files\nodejs\node_modules\npm\node_modules\express-spdy>node app.js
module.js:340
throw err;
^
Error: Cannot find module 'express-spdy'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\express- spdy\app.js:6:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Please tell me how to resolve this error, as I have put express-spdy inside node_modules folder.
When I run the example using SPDY module only by placing it inside node_modules it works fine but with express-spdy module it shows above error.

Underscore with nodejs and forever

I have a nodejs app and a module in a /lib folder that requires underscore. When I run nodejs, everything works fine but when I try to use forever with this command: NODE_ENV=production forever start -l forever.log -o out.log -e err.log app.js I have this error in forever.log:
module.js:340
throw err;
^
Error: Cannot find module 'underscore'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/nodejs_app/lib/utils.js:1:71)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
error: Forever detected script exited with code: 8

Resources