log4js is not working on gae with nodejs - node.js

I am trying to deploy node project on google app engine using
gcloud app deploy
But this is throwing error
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
module.js:471
throw err;
^
Error: Cannot find module 'log4js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/server.js:38:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
The same project is working on local machine. Here is my package.json
{
"name": "myapp",
"version": "1.0.0",
"description": "myapp",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"body-parser": "^1.15.0",
"connect-timeout": "^1.8.0",
"express": "^4.13.4",
"generic-pool": "^2.4.2",
"multer": "^1.2.0",
"mysql": "^2.10.2",
"requestify": "^0.1.17"
}
}
What is the issue?

log4js is missing in your dependencies.
npm install log4js --save to add it to your package.json.

Related

Error : Cannot find Module 'cors' in fabric 1.2

I was getting Error: Cannot find module 'fabric-client'error then manually I ran 'npm install fabric-client#1.0.5' inside node_module then I am getting below error
[root#ip-172-31-61-27 controller]# node app.js module.js:538
throw err;
^
Error: Cannot find module 'cors'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ec2-user/AWSNodeApp/controller/app.js:27:11)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
We already have an entry of 'cors' in the package.json file but still it given above error.
Below is the package.json file :-
{
"name": "awsnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.538.0",
"body-parser": "^1.17.1",
"cors": "^2.8.3",
"express": "^4.15.2",
"express-session": "^1.15.2",
"fabric-ca-client": "1.3.0",
"fabric-client": "1.3.0",
"fs-extra": "^2.0.0",
"log4js": "^3.0.6",
"uuid": "^3.3.2",
"ws": "^6.1.0"
}
}
Since your app.js requires cors module, you need to install and add to package.json.
npm install cors --save
You can find the answer from this old post: Error: Cannot find module 'cors'

NodeJS: Module did not self-register

I am trying IBM Watson's Speech to Text API. While running my NodeJS app I get this.
I am using line-in package for streaming the input audio data in output, in addition to IBM Watson's SpeechToText package.
I tried removing node_modules and $ npm install and $ npm rebuild. Nothing worked.
node app.js
internal/modules/cjs/loader.js:718
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: Module did not self-register.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (F:\Topgear\SpeechToText\node_modules\line-in\index.js:2:20)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)```
package.json
{
"name": "SpeechToText",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"dotenv": "^8.0.0",
"line-in": "^0.1.2",
"watson-developer-cloud": "^4.0.1"
},
"devDependencies": {},
"scripts": {
"test": "mocha"
},
"keywords": [],
"author": "Nikhilesh AS",
"license": "ISC"
}

google cloud platform: "Can't find module firebase-admin"

I am trying to deploy my node.js server to google cloud platform.
It works perfectly when I use it locally (run it with npm start of node app.js).
But when I try to deploy it (gcloud deploy), it failed, and in the Log:
Error: Cannot find module 'firebase-admin' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/app/app.js:28:16) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)
in app.js i use simply:
var firebase = require("firebase-admin");
and this is my package.json file:
{
"name": "Talk2Me-server",
"version": "1.0.3",
"main: "app.js",
"description": "Talk2Me app server",
"private": true,
"license": "Apache-2.0",
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/guytsur/Talk2Me.git"
},
"author": "Talk2Me Team,",
"contributors": [
"Guy Tsur<guytsur7#google.com>"
],
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true
},
"dependencies": {
"express": "~4.15.2",
"request": "^2.81.0",
"firebase-admin": "^4.1.2",
"firebase": "^2.4.2"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "1.4.16",
"ava": "~0.21.0",
"supertest": "~3.0.0",
"tap-dot": "~1.0.5"
},
"engines": {
"node": ">=4.3.2"
}
}
Thanks!
Ok i managed to solve it,
first thing i reinstalled the packages using
npm install --save firebase-admin
and than i also did a little hack, i added to the package file:
"scripts": {
"start": "npm install firebase-admin; node app.js"
},
which i guess isn't the best of practice, but it worked.

Error: Cannot find module 'lodash/keys' - Heroku Node environment

I keep getting this error when deploying my Node and Mean app to Heroku. The app seems to work normally when I run it locally but does not like it when I push it to Heroku.
module.js:471
throw err;
^
Error: Cannot find module 'lodash/keys'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/node_modules/mongoose/node_modules/async/internal/iterator.js:16:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
This is my package.json file
{
"name": "utdknow",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.6.12",
"body-parser": "^1.14.1",
"crypto-js": "^3.1.8",
"ejs": "^2.3.4",
"express": "^4.13.3",
"lodash": "^4.17.3",
"lodash.keys": "^4.2.0",
"moment": "^2.17.0",
"mongoose": "^4.2.5",
"ng-file-upload": "^12.0.4"
}
}
It seems like modules are not correctly installed. Try cleaning cache and deploy your app to re-install all dependencies:
https://github.com/heroku/heroku-repo
heroku plugins:install heroku-repo
heroku repo:purge_cache --app appname

how to start global npm module with harmony flag

I wrote a npm module which can be installed globally dm-npm.
I like to use co in that module.
How can i told the module that it runs with the harmony flag when started globally?
Here is the package.json:
{
"name": "dm-npm",
"version": "0.0.3",
"description": "npm helper",
"main": "index.js",
"scripts": {
"test": "mocha --reporter nyan",
"start": "node --harmony ./bin/dm-npm"
},
"repository": {
"type": "git",
"url": "https://github.com/divramod/dm-npm.git"
},
"keywords": [
"npm",
"template"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/divramod/dm-npm/issues"
},
"homepage": "https://github.com/divramod/dm-npm",
"devDependencies": {
"chai": "^2.1.0",
"mocha": "^2.1.0"
},
"dependencies": {
"co": "^4.4.0",
"co-prompt": "^1.0.0",
"colors": "~1.0.3",
"shelljs": "^0.3.0"
},
"bin": {
"dmnpm": "./bin/dm-npm"
}
}
i got the following error message when running with a co function:
> $ dmnpm init
/usr/local/lib/node_modules/dm-npm/index.js:152
co(function*() {
^
SyntaxError: Unexpected token *
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/dm-npm/bin/dm-npm:3:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
it is caused by
co(function*() {
var projectName =
yield prompt('project name: '.blue);
process.stdin.pause();
});
#!/usr/bin/env node --harmony
on the top of script works for me, in your case in /bin/dm-npm

Resources