'invalid ELF header' error when loading libyaml module - node.js

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.

Related

ng serve : Cannot find module './templates.js'

I just transfered my Angular 6 project from one computer to another and in the new device I get the following error when trying to ng serve
I have also tried with npm install templates.js , the dependency is installed but this error pops again
Cannot find module './templates.js'
Error: Cannot find module './templates.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Godwin\Desktop\livigro\node_modules\chalk\index.js:6:18)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Godwin\Desktop\livigro\node_modules\postcss\lib\css-syntax-error.js:9:14)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
This could be similar to ng serve: Cannot find module 'tapable'
Thanks in Advance :)
Removing the node_modules folder and again using npm install solves the problem , and the ng serve working good
It can occur for two reasons:
1. templates.js is not present.
2. templates.js is present but you provided the wrong relative path.
Kindly check once. And you don't need to install "templates.js" if it's not an external package. Npm install is used for installing the external packages.

Unknown error running phantomjs in Ubuntu 14.04

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.

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.

'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

Nodejs +nowjs + Windows

I tried installing nodejs and it works fine, I was able to get it running.
Followed exactly the steps shown here:
http://blog.nowjs.com/running-nowjs-natively-on-windows
Then I tried to install the nowjs and run the multiroomchat_server.js example and got this error:
[Error: The specified procedure could not be found.
C:\Program Files (x86)\nodejs\node_modules\now\bin\proxy.node]
Error: The specified procedure could not be found.
C:\Program Files (x86)\nodejs\node_modules\now\bin\proxy.node
at Object.Module._extensions..node (module.js:480: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> (C:\Program Files (x86)\nodejs\node_modules\now\lib\pr
oxy.js:10: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)
I'm running windows 7 64bit, installed the 32bit version of node.js node-v0.8.1-x86.msi.
Anyone got it running?
Try newer version of node.
Works on Win 7 x64 with node-v0.8.5-x64

Resources