Unknown error running phantomjs in Ubuntu 14.04 - node.js

While running phantomjs module in nodejs, I got this strange error
phantom stderr: Fontconfig warning: ignoring UTF-8: not a valid region tag
/var/www/myWeb/Web/Front/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:83
throw e
^
Error: /var/www/myWeb/Web/Front/node_modules/phantom/node_modules/dnode/node_modules/weak/build/Release/weakref.node: invalid ELF header
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 bindings (/var/www/myWeb/Web/Front/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/var/www/myWeb/Web/Front/node_modules/phantom/node_modules/dnode/node_modules/weak/lib/weak.js:7:35)
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)
Can anyone tell me how to solve it? It always causes the nodejs app to crash. I tried rebuilding the phantomjs node module, reinstalling the latest phantomjs like this one, and still the error showed up. I tried building the phantomjs source, but apparently my machine didn't have enough virtual memory. :(

It turns out that ubuntu download different files when I run npm install. So in my computer (OSX) it runs fine while on ubuntu, it crashes. To resolve it, I run npm remove then npm install again.

Related

Running a npm: "Symbol is not defined"

I'm trying to use: https://github.com/siddharthkp/cost-of-modules
I have npm3 installed on Centos 6.4. When I try to run it I got this error:
[root#XXX public]# cost-of-modules
Making sure dependendies are installed
npm install --production
Calculating...
/usr/local/lib/node_modules/cost-of-modules/lib/helpers.js:167
throw _iteratorError2;
^
ReferenceError: Symbol is not defined
at Object.getSizeForNodeModules (/usr/local/lib/node_modules/cost-of-modules/lib/helpers.js:145:36)
at Object.<anonymous> (/usr/local/lib/node_modules/cost-of-modules/lib/index.js:19:27)
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
Don't know why it calls to "npm install" I already have npm3 installed. I already asked in the Github's module but I thinks it's not related to that specific module. Please, any help would be appreciated. Thanks.
It was a bug on cost-of-modules. It's solved now here:
https://github.com/siddharthkp/cost-of-modules/issues/24

npm doesn't work on an ARM embedded device

I installed Node.js on an embedded device running with a core Linux 3.0.
When I try to execute npm to install some modules, I get the follow issue :
DM-37x# npm
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
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 /usr/local/bin/npm:18:11
at Object.<anonymous> (/usr/local/bin/npm:86:3)
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)
I already tried to reinstall node.js but the bug is still here.
How can I do to fix this problem?
Try installing (or reinstalling) npmlog.
See https://www.npmjs.org/package/npmlog
Make sure you have a package.json file in the top level of your project directory (each project).
Use npm ls
and
npm update
to make sure the npmlog package is included.

Apparently I deleted some of the files on the node_module, how can I restore them?

I was trying to install node trough brew and it was giving a lot of errors, and apparently some file was not giving the permission, so I thunked that the file was from other failed try to intall node and I decide to remove the directory. It failed to remove the dir and the files, but apparently some had been erased.
They are:
module.js:340
throw err;
^
Error: Cannot find module 'child-process-close'
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 /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object. (/usr/local/lib/node_modules/npm/lib/npm.js:461:3)
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)
How can I solve this? I just wanted to try sails.js for fun, but I didn't see any fun time yet, only problems.
Thank you
It appears that your issue is not with the sails global or project installation, but rather that you corrupted the nodejs installation. I'd recommend you to just download nodjs again from nodejs.org (this downloads a .pkg) and install it with that package.
If this complains about permissions and overwriting things (which I don't think), try first deleting the whole node_modules folder with sudo:
sudo rm -fr /usr/local/lib/node_modules
I know this is super late. However, I was getting this same error while trying get a react native app up and running.
I installed node with HomeBrew and after getting the following:
Error: Cannot find module 'child-process-close'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:520:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
I then ran
brew postinstall node
and got:
Permission denied - /usr/local/lib/node_modules/npm/AUTHORS
So then I ran:
sudo brew postinstall node
and it seemed to work fine. I could go about installing waterline, firebase, or whatever else I tried.
Hope this helps!
Run npm install from your project directory to re-install all modules listed in your package.json.

'invalid ELF header' error when loading libyaml module

When I go into node and attempt to require libyaml I get:
> require('libyaml')
Error: /home/ubuntu/shadow/node_modules/libyaml/build/Release/binding.node: invalid ELF header
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/ubuntu/shadow/node_modules/libyaml/index.js:7:15)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I'm using node version 0.8.12 and libyaml version 0.2.1. Curiously the error is server dependent, but it doesn't seem to be based on the version numbers, because it runs fine on one of boxes with the same versions.
One can also use 'npm rebuild module-name' to recompile the C code on the deployment machine as part of preinstall script.
Documentation
Thanks vinayr for advising me to run npm install on the production box. The issue is that they needed to install npm differently. I resolved that with a pre-deploy command on the box as part of the deploy. Problem solved.

Install node-expat on ubuntu or centos

I'm trying to install node-expat. I've tried everything suggested that I could find. I don't get any build errors while running npm install node-expat. I've put in all the dependencies & building kits, tried npm cache clean & tried it on both CentOS (Amazon Linux) and Ubuntu 12.10 but the error remains the same:
module.js:485
process.dlopen(filename, module.exports);
^
Error: Module version mismatch, refusing to load.
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/ubuntu/cc/node_modules/node-expat/lib/node-expat.js:4:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
How can I get it to run without hitches?
The reason I want node-expat is for node-xmpp
This may or may not help you, but I was getting the same error with an appjs app I'm working on, and I just figured out what was causing it for me. I have node v0.10.x installed on my machine, but I was building the modules to include them in an appjs app (which currently comes packaged with v0.8.x of node.exe. So I was building the module with 0.10, but trying to run it on 0.8.
I uninstalled my node 0.10, installed 0.8, rebuilt/installed the offending module into my appjs app, and the error went away. So make sure you're building the module with the same version of node you're trying to run it on!

Resources