When datejs is installed using npm and when a script (below) is executed, the following error is obtained:
Error: Cannot find module 'datejs'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
datejs module exists under correct node_modules.Thanks in advance.
Try require('./node_modules/datejs/index.js');
Related
I'm using NPM programmatically in a project which is compiled to binary in the end. Upon using npm.commands.install when running the binary file the following error is thrown:
[2018/09/08 19:55:59:0503] LOG: POST -> /processor/mutator/install
{ Error: Cannot find module 'node-gyp/bin/node-gyp'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Function.Module._resolveFilename (module.js:545:15)
at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1278:46)
at resolveFileName (/snapshot/chisel/node_modules/npm/node_modules/npm-lifecycle/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/snapshot/chisel/node_modules/npm/node_modules/npm-lifecycle/node_modules/resolve-from/index.js:43:9)
at module.exports (/snapshot/chisel/node_modules/npm/node_modules/npm-lifecycle/node_modules/resolve-from/index.js:46:41)
at Object.<anonymous> (/snapshot/chisel/node_modules/npm/node_modules/npm-lifecycle/index.js:18:31)
at Module._compile (pkg/prelude/bootstrap.js:1252:22)
at Object.Module._extensions..js (module.js:661:10)
at Module.load (module.js:563:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Module.require (module.js:594:17)
at Module.require (pkg/prelude/bootstrap.js:1157:31)
at require (internal/module.js:11:18)
at Object.<anonymous> (/snapshot/chisel/node_modules/npm/lib/utils/lifecycle.js:4:19)
at Module._compile (pkg/prelude/bootstrap.js:1252:22) code: 'MODULE_NOT_FOUND', pkg: true }
I've tried doing npm install node-gyp inside node_modules/npm and also inside my own project to have Pkg include it inside the binary.
Not sure if switching to child_process is possible while Node.js and NPM are packed inside the binary file (I'm trying to keep the binary file independent of Node.js and NPM).
Any help/alternatives would be appreciated.
pkg compiler bundles all your node_module script into the compiled binary. But when, one of dependencies using some external binaries like node-gyp executable (inside node_modules/node-gyp/bin/node-gyp), phanthom js and etc, the pkg cannot do the compilation. You will have to avoid those dependencies if you want to compile your code with pkg module.
Otherwise you can refactor the node-gyp module and separate the executable them ship it with your compiled binary, which could be an advanced alternative and time consuming.
This error with OpenCV (I'm trying to use Node + OpenCV - as in node-opencv) has been driving me crazy. I've looked at many answers on StackOverflow or otherwise, and I think this could be a problem with the upgraded Homebrew or maybe with OpenCV. Unless it is a problem with the way I imported OpenCV.
Does anyone understand this/know what to do?
module.js:598
return process.dlopen(module, path._makeLong(filename));
^
Error: dlopen(/Users/Joe/SRS/node_modules/opencv/build/opencv/v6.0.0/Release/node-v51-darw
in-x64/opencv.node, 1): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
Referenced from: /usr/local/opt/opencv/lib/libopencv_highgui.2.4.dylib
Reason: image not found
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/Joe/SRS/node_modules/opencv/lib/bindings.js:4:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
I was getting the same error and reinstalling Open CV fixed it. I ran
brew reinstall --build-from-source opencv.
I’m installing scrypt (https://www.npmjs.com/package/scrypt) from npm. The installation involves a node-gyp build step that builds a native node.js extension. When I then start my app, it fails with the following error:
node index.js
module.js:568
return process.dlopen(module, path._makeLong(filename));
^
Error: /package/host/localhost/gcc-4/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/xxxx/xxxx/node_modules/scrypt/build/Release/scrypt.node)
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/xxxx/xxxx/node_modules/scrypt/index.js:3:20)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/xxxx/xxxx/node_modules/unfun-cms/lib/utils/password.js:3:16)
which is not so surprising, because
[xxxx#xxxx nodeapp]$ strings /package/host/localhost/gcc-4/lib64/libstdc++.so.6 | grep "GLIBCXX_3\.4\.21"
[xxxx#xxxx nodeapp]$
while
[xxxx#xxxx nodeapp]$ strings /package/host/localhost/gcc-5/lib64/libstdc++.so.6 | grep "GLIBCXX_3\.4\.21"
GLIBCXX_3.4.21
[xxxx#xxxx nodeapp]$
I have
export PATH=/package/host/localhost/gcc-5/bin:$PATH
export LD_LIBRARY_PATH=/package/host/localhost/gcc-5/lib64:$LD_LIBRARY_PATH
in my .bashrc, and gcc --version shows 5.2.0 correctly, so I assume these settings are alright.
So the question is, how do I tell scrypt the path to the correct libstdc++.so.6, namely the one at /package/host/localhost/gcc-5/lib64/libstdc++.so.6? (And why does it even get it wrong?)
EDIT:
This is a CentOS machine. I’m using node.js version 6.1.0, npm version 3.8.6, and I’m trying to install scrypt version 6.0.3, which is the latest version at the time of this writing.
EDIT 2:
I tried to statically link the library by editing node_modules/scrypt/binding.gyp, adding
'libraries': ['/package/host/localhost/gcc-5/lib64/libstdc++.so.6'],
to each of the four specified targets, and then running node-gyp rebuild.
I also tried changing this to
'libraries': ['-L/package/host/localhost/gcc-5/lib64', '-lstdc++'],
, which appears to be syntactically valid, too—but still, it tries to load the library from the wrong path at runtime.
I stubled with a similar trouble and had resolve it with a trick uses dynamic load of libstdc++.so.6 through LD_PRELOAD:
LD_PRELOAD='/path/to/lib/libstdc++.so.6' /usr/bin/nodejs app.js
When I compile code with
\> jx package bin/www.js myApp
\> packaging...
\> [OK] compiled file is ready (myApp.jx)
it successfully created myApp.jx and myApp.jxp
But when I executed command
\> jx myApp.jx
It gives errors as:
C:\**\node_modules\express-session\node_modules\debug*node.js.jx*:72
exports.formatters.o = function(v) {
^
TypeError: Cannot set property 'o' of undefined
at Object. (C:\**\node_modules\express-session\node_modules\debug\node.js.jx:72:22)
at Module._compile (module.js:519:26)
at Object.Module._extensions..jx (module.js:1604:7)
at Module.load (module.js:346:36)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:378:17)
at require (module.js:396:17)
at Object. (C:\**\node_modules\express-session*index.js.jx:17:13*)
at Module._compile (module.js:519:26)
at Object.Module._extensions..jx (module.js:1604:7)
at Module.load (module.js:346:36)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:378:17)
at require (module.js:396:17)
at Object. (C:\***server.js.jx*:7:15)
at Module._compile (module.js:519:26)
I dont think,the problem is with NPM, step by step compile each of the .js file, and introduce required NPM package one by one , you will get the solution.
Since it is not a JXcore issue (the app fails with node too), you might want to seek the problem related with js-bson: Failed to load c++ bson extension, using pure JS version.
For example I saw this answer: Failed to load c++ bson extension, and they say it could be fixed by reinstalling modules with npm install.
I am newbie to MEAN stack and Linux hence please forgive me if my question is too obvious and stupid.
I have hosted a Nodejs application on Openshift. While trying to start the application I am facing following error due to GLIBC library version missmatch:
[Error: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build/Release/bson.node)]
js-bson: Failed to load c++ bson extension, using pure JS version
/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js:8
var ObjectId = require('mongodb').BSONPure.ObjectID;
^
TypeError: Cannot read property 'ObjectID' of undefined
at Object.<anonymous> (/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js:8:43)
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> (/var/lib/openshift/550be20dfcf93378d600015e/app-root/runtime/repo/node_modules/mongoose/lib/types/objectid.js:18:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Current version of GLIBC on Opneshift is 2.12.
One obvious solution which I know is to upgrade GLIBC on Openshift. However that is not feasible as I am not having sudo rights on openshift.
Is there any possible workaround to solve the same issue?