node.js and node-postgres syntax error - javascript

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.

Related

npm require fails to detect simple-peer module

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');

Heapdump error when running iron-node

I get this error when launching iron-node
buster-test run failed: Error: -c/--config: Error loading configuration /Users/r01010010/Projects/Mad/paysite/test/buster.js
Cannot find module '../build/Debug/addon'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/r01010010/Projects/Mad/paysite/node_modules/heapdump/lib/main.js:18:15)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
No idea on how to solve this.
Env: Node.js v0.10.40 with nvm, node-gyp v3.2.1
With iron-node you do not need this Module. You can read and write such things within dev-tools-window in the Profiles tab. There ist also this document which provides more details. https://github.com/s-a/iron-node/blob/master/docs/PROFILE.md

flylatex dosen't find all modules

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.

js2coffee throws cannot find module error

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

Running UglifyJS under node.js generates cannot find module error

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.

Categories

Resources