I have js2coffee installed globally and I tried
js2coffee app.js > app.coffee
And I got the following error
module.js:340
throw err;
^
Error: Cannot find module 'nopt'
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> (/usr/lib/node_modules/js2coffee/out/lib/command.js:16:10)
at Object.<anonymous> (/usr/lib/node_modules/js2coffee/out/lib/command.js:273:4)
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 Object.<anonymous> (/usr/lib/node_modules/js2coffee/out/bin/js2coffee: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:901:3
Does anyone know how to fix this?
It appears that the nopt module is a devDependency of js2coffee and isn't installed during production.
To fix this, navigate to js2coffee's module folder and run npm install. That will also install development dependencies, although I'm not sure why js2coffee needs them the way you're using it.
So if you're using running a Linux machine, use these commands:
cd /usr/lib/node_modules/js2coffee
npm install
It seems like you installed the package globally using -g option.Try installing the package like
npm install package
in the project directory
Related
I Have installed the below npm module
https://github.com/feross/simple-peer
by,
#sudo npm install simple-peer -g
But When tried including the module, it is unable to find the module. I received the below error
module.js:340
throw err;
^
Error: Cannot find module 'simple-peer'
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> (/home/cst/poc/test.js:1:73)
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)
In my sample code I just had
var pee = require('simple-peer');
I'm getting the following error when I try to use "grunt serve".
/Users/name/Documents/projectname/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.js:6755
});
SyntaxError: Unexpected end of input
at Module._compile (module.js:439:25)
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 Object.<anonymous> (/Users/name/Documents/projectname/node_modules/grunt/node_modules/findup-sync/lib/findup-sync.js:16:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Any help would be appreciated. Thank you!
-Dave
I had a similar issue that produced the same SyntaxError: Unexpected end of input error for me. Resolution for this was to remove my project's node_modules directory and re-run npm install. If you are using a linux machine make sure to run it as sudo npm install whereas on windows you'll want to run your command prompt as Admin. Hope this helps!
If I run flylatex from github, get the following Error on Debian and Ubuntu. Is my nodejs stuff broken or has flylatex a error? At first I run npm install -d in the working directory. My version of nodejs is 0.10.25. The last output is npm info ok Has anyone an idea for fixing the problem?
rennecke#odin ~/flylatex ±master » nodejs app.js
module.js:340
throw err;
^
Error: Cannot find module './src'
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> (/home/rennecke/flylatex/node_modules/share/index.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 Object.<anonymous> (/home/rennecke/flylatex/app.js:10:13)
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 had the same problem.
It's a "nodejs and coffee script" problem.
You have to find a way to explain to "nodejs" how to "compile on the fly" coffee script.
I was not able to find the solution but, on my side, the ./node_modules/share/src of coeffeescript was already compile in javascript in the ./node_moudules/share/lib
So I just edit the file :
./node_modules/share/index.js
comment the 2 lines
// require ('coffee-script');
// module.exports = require('./src'):
and add the line
module.exports = require('./lib');
And it's work.
I am still looking for a more "elegant" solution for a "one line" compilation of coffescript.
hope this helps.
I just installed node-postgres by running npm install pg .
In my source code, I added var pg = require('pg");
and when I run I now get
module.js:340
throw err;
^
Error: Cannot find module 'pg'
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/rrazavipour-lp/Documents/workspace/Astute/app.js:9:10)
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.runMain [as _onTimeout] (module.js:497:10)
What step am I missing?
Where is the node_modules folder in relation to your application?
from http://nodejs.org/api/modules.html:
If the module identifier passed to require() is not a native module, and does not begin with '/', '../', or './', then node starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location.
Running node.js v0.10.15 on windows 7 - installed VIA node-v0.10.15-x86.msi.
Downloaded latest UglifyJS2 library.
Created batch file with syntax:
node "path\to\uglifyjs\bin\uglifyjs" -o "file.min.js" "file.js"
Getting error:
module.js:340
throw err;
Error: Cannot find module 'source-map'
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> (D:\Projektid\Tools\uglifyjs\tools\node.js:9:21)
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)
What could be the problem?
It seems that you've used node instead of uglify in the command line. Since uglifyjs is its own CLI, you don't need to call on node. I believe you need to have this installed globally to work as intended.
npm install uglify-js -g
then
uglifyjs "path\to\uglifyjs\bin\uglifyjs" -o "file.min.js" "file.js"
should work.