Debug Error with log4js appender when starting npm - javascript

When starting npm I am facing an error. The error states that "Error: log4js configuration problem for { type: 'log4js-syslog-appender'," Essentially seems like the format for the log4js config might be wrong. I am a complete newbie to node and would appreciate any pointers on what may be a good next step here.
I have inherited a bunch of code that was written with Node 4.2 and npm 3.x I have had to compile openssl fips binaries and then recompile and reinstall node (6.11.1) and npm with it (3.10.10). I am now simply trying to do npm start and running into an error.
Config.js looks like this for the log4js part:
/*
|--------------------------------------------------
| Logging
|--------------------------------------------------
*/
var log4js = require('log4js');
var use_syslog = process.env.LOG_SYSLOG == "true";
var appenders = [ { type: 'console' } ];
if (use_syslog) {
appenders.push({ type: 'log4js-syslog-appender',
tag: 'API',
facility: 'local0',
path: '/dev/log',
transport: 'socket' });
}
log4js.configure({
appenders: appenders
});
config.logger = use_syslog ? log4js.getLogger('syslog') : log4js.getLogger('console') ;
config.logger.setLevel(process.env.DEBUG_LEVEL);
I would like to find a way to solve this error but cannot figure out what exact change I need to make in the config.js file. If any direction can be provided it'll be great.
The exact error is as below:
==========================================================================
oi#oi01:~/api$ npm start
> oi-api#2.0.0 start /home/oi/api
> babel-node server.js --presets es2015
/home/oi/api/node_modules/log4js/lib/log4js.js:316
throw new Error(
^
Error: Problem reading log4js config { appenders:
[ { type: 'console', makers: [Object] },
{ type: 'log4js-syslog-appender',
tag: 'API',
facility: 'local0',
path: '/dev/log',
transport: 'socket',
makers: [Object] } ] }. Error was "log4js configuration problem for { type: 'log4js-syslog-appender',
tag: 'API',
facility: 'local0',
path: '/dev/log',
transport: 'socket',
makers:
{ console: [Function: bound configure],
'log4js-syslog-appender': [Function: bound configure] } }" (Error: log4js configuration problem for { type: 'log4js-syslog-appender',
tag: 'API',
facility: 'local0',
path: '/dev/log',
transport: 'socket',
makers:
{ console: [Function: bound configure],
'log4js-syslog-appender': [Function: bound configure] } }
at /home/oi/api/node_modules/log4js/lib/log4js.js:256:15
at Array.forEach (native)
at configureAppenders (/home/oi/api/node_modules/log4js/lib/log4js.js:248:18)
at configureOnceOff (/home/oi/api/node_modules/log4js/lib/log4js.js:308:7)
at Object.configure (/home/oi/api/node_modules/log4js/lib/log4js.js:371:3)
at Object.<anonymous> (/home/oi/api/config/config.js:92:8)
at Module._compile (module.js:570:32)
at loader (/home/oi/api/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/oi/api/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32))
at configureOnceOff (/home/oi/api/node_modules/log4js/lib/log4js.js:316:13)
at Object.configure (/home/oi/api/node_modules/log4js/lib/log4js.js:371:3)
at Object.<anonymous> (/home/oi/api/config/config.js:92:8)
at Module._compile (module.js:570:32)
at loader (/home/oi/api/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/oi/api/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
npm ERR! Linux 4.4.0-1002-fips
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! oi-api#2.0.0 start: `babel-node server.js --presets es2015`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the oi-api#2.0.0 start script 'babel-node server.js --presets es2015'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oi-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel-node server.js --presets es2015
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs oi-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls oi-api
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/oi/api/npm-debug.log
===============================================================

Related

Can't start webpack development server

I am new on es6. I followed a blog Beginner’s Guide To Setup ES6 Development Environment. I completed all of the process step-by-step. Then the step comes up to install the webpack development server. Then I write this code to cmd - npm run build. I get this error:
λ npm run build
-> jj#1.0.0 build C:\Users\galib\Desktop\jj
-> webpack-dev-server
The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\galib\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\galib\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\web
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\galib\\AppData\\Roaming\\npm\\node_modules\\webpack-dev-server\\bin\\webpack-dev-serv
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jj#1.0.0 build: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jj#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\galib\AppData\Roaming\npm-cache\_logs\2021-06-08T18_22_59_337Z-debug.log
The article you read was probably written before Webpack's cli was moved to webpack-cli, so you might need one small extra step.
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
Run npm i -D webpack-cli and then you can use the Webpack CLI.

log4js npm error , log4js configuration

root#------:~# cd /home/bot
root#------:/home/bot# node site.js
/home/bot/node_modules/log4js/lib/configuration.js:43
throw new Error(Problem with log4js configuration: (${util.inspect(this.candidate, { depth: 5 })}) +
^
Error: Problem with log4js configuration: ({ appenders:
[ { type: 'console' },
{ type: 'file', filename: 'logs/site.log' } ] }) - must have a property "appenders" of type object.
at tests.forEach (/home/bot/node_modules/log4js/lib/configuration.js:43:15)
at Array.forEach (native)
at Configuration.throwExceptionIf (/home/bot/node_modules/log4js/lib/configuration.js:41:11)
at new Configuration (/home/bot/node_modules/log4js/lib/configuration.js:203:10)
at Object.configure (/home/bot/node_modules/log4js/lib/log4js.js:205:12)
at Object. (/home/bot/site.js:12:8)
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)
i use command npm install log4j --save
root#------:/home/bot# npm install log4j --save
npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nave/installed/6.11.1/bin/node" "/root/.nave/installed/6.11.1/bin/npm" "install" "log4j" "--save"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/log4j
npm ERR! 404
npm ERR! 404 'log4j' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /home/bot/npm-debug.log
I had the same problem as u with the same script xD.
I found a solution!!!!!!!!!!!!!
U need to change thelog4js.configure in your site.js to this
log4js.configure({
appenders: {
out: { type: 'console' },
task: { type: 'file', filename: 'logs/site.log' }
},
categories: {
default: { appenders: [ 'out' ], level: 'info' },
task: { appenders: [ 'task' ], level: 'info' }
}
});

sequelize is not defined (nodejs)

I'm new to nodejs, trying to make an API by walking through the guide, but got an issue I can't resolve even with google tho.
Here's my command line text.
consign v0.1.2 Initialized in d:\Jinn\API
+ .\libs\config.js
+ .\db.js
+ .\libs\middlewares.js
+ .\routes\index.js
+ .\routes\tasks.js
+ .\libs\boot.js
d:\Jinn\API\db.js:22
sequelize = new _sequelize2.default(config.database, config.username, config
.password, config.params);
^
ReferenceError: sequelize is not defined
at Function.module.exports (d:/Jinn/API/db.js:10:5)
at Consign.into (d:\Jinn\API\node_modules\consign\lib\consign.js:239
:17)
at Object.<anonymous> (d:/Jinn/API/index.js:13:4)
at Module._compile (module.js:570:32)
at loader (d:\Jinn\API\node_modules\babel-register\lib\node.js:144:5
)
at Object.require.extensions.(anonymous function) [as .js] (d:\Jinn\API\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Function.Module.runMain (module.js:604:10)
at d:\Jinn\API\node_modules\babel-cli\lib\_babel-node.js:161:27
at Object.<anonymous> (d:\Jinn\API\node_modules\babel-cli\lib\_babel
-node.js:162:7)
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)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! api#1.0.0 start: `babel-node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api#1.0.0 start script 'babel-node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bitskinsapi package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel-node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls api
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! d:\Jinn\API\npm-debug.log
Seems that troubles are somewhere in db.js file so here is the code of it:
import fs from "fs";
import path from "path";
import Sequelize from "sequelize";
let db = null;
module.exports = app => {
if (!db) {
const config = app.libs.config;
sequelize = new Sequelize(
config.database,
config.username,
config.password,
config.params
);
db = {
sequelize,
Sequelize,
models: {}
};
// Загрузка моделей
const dir = path.join(__dirname, "models");
fs.readdirSync(dir).forEach(file => {
const modelDir = path.join(dir, file);
const model = sequelize.import(modelDir);
db.models[model.name] = model;
});
Object.keys(db.models).forEach(key => {
db.models[key].associate(db.models);
});
}
return db;
};
To tell the truth I mostly followed instructions and copy-pasted code fragments that's why I'm frustrated because it should work. Any thoughts?

Node.js with parse.com (ParseOpenSource javascript sdk) installed - fails on AWS eb deploy

I am trying to 'eb deploy' a node.js with javascript sdk addition.
It works fine locally but every time I have tried to - eb deploy- it I get this in the logs
npm ERR! npm bugs node-express
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-express
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> node-express#0.0.0 start /var/app/current
> node main.js
{ [Error: ENOENT: no such file or directory, open '.env'] errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
module.js:327
throw err;
^
Error: Cannot find module 'parse/node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/app/current/api/common/parse.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
...npm ERR! code ELIFECYCLE
npm ERR! node-express#0.0.0 start: `node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-express#0.0.0 start script 'node main.js'.
npm ERR! This is most likely a problem with the node-express package,
I have repeatedly tried
npm install express --save
and yes I have also run npm install parse (it all works fine locally).
To no avail. Why would it all work like a charm locally but not on AWS EB ?
-Thanks for any clues.
Not sure if this will help someone. Ultimately I solved this by
'npm install moduleName --save' on all of my modules. One by one.
Still not sure why the site worked locally ?
-best of luck.

Error when running "npm start"?

I have started with electron today and followed a guide to create a simple application browser window and I ran npm start in the command window and it displayed a lot of errors after I had entered it, I have posted the information below and my code.
Console error:
C:\Users\Administrator\Desktop\electron>npm start
> breef#1.0.0 start C:\Users\Administrator\Desktop\electron
> node index.js
module.js:471
throw err;
^
Error: Cannot find module 'app'
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> (C:\Users\Administrator\Desktop\electron\index.js:1:73)
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)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! breef#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the breef#1.0.0 start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the breef package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs breef
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls breef
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Administrator\Desktop\electron\npm-debug.log
Here is my package.json:
{
"name": "breef",
"version": "1.0.0",
"description": "A simple chat application.",
"main": "index.js",
"dependencies": {
"electron": "^1.4.12"
},
"devDependencies": {},
"scripts": {
"test": "breeftestcmd",
"start": "node index.js"
},
"keywords": [
"breef"
],
"author": "Sage & Sh4wn",
"license": "ISC"
}
Here is my index.js:
var app = require("app")
var browserWindow = require("browser-window")
app.on('ready', function() {
var mainWindow = new browserWindow({
width: 800,
height: 600
})
mainWindow.loadUrl('http://google.com');
})
If app is a module, it's missing in your package.json. If not, you should use a path to require it
var app = require('./app');
The guide you followed is out of date, as of Electron v1.0.0 the way built-in Electron modules are imported has changed. This is the correct way:
const {app, BrowserWindow} = require("electron")
You may also find it beneficial to read the previous question that covered this topic: What's the proper way to require in Node.js?

Categories

Resources