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' }
}
});
Related
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
===============================================================
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?
When i run my first react app using npm start command some error is displayed. Please some one help me to resolve this issue.
C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:386
throw e;
^
Error: `output.path` needs to be an absolute path or `/`.
at Object.setFs (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:88:11)
at Shared (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:214:8)
at module.exports (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\middleware.js:22:15)
at new Server (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\lib\Server.js:56:20)
at startDevServer (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:379:12)
at processOptions (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:317:3)
at Object.<anonymous> (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:441:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! r3#1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the r3#1.0.0 start script 'webpack-dev-server'.
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 r3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs r3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls r3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\ankit\Desktop\r3\npm-debug.log
The error message is clear: output.path needs to be an absolute path or /
Your output.path should write like this:
var path = require('path');
output: {
path: path.join( __dirname, './dist/'),
}
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?
I am trying to import a file with an absolute path into my main electron thread.
Import code in the main electron thread:
import * as Test2 from 'app/main/tray.js';
I have added the resolve.root to the webpack.config:
{
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['babel-loader'],
exclude: /node_modules/,
}, {
test: /\.json$/,
loader: 'json-loader',
}],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]/index.js',
libraryTarget: 'commonjs2',
},
resolve: {
root: [
path.resolve('./')
],
extensions: ['', '.js', '.jsx'],
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
},
plugins: [
],
externals: [
// put your node 3rd party libraries which can't be built with webpack here
// (mysql, mongodb, and so on..)
],
};
No errors are thrown when I run the webpack server (webpack finds the files just fine) but an error is thrown when I run electron.
App threw an error during load
Error: Cannot find module 'app/main/tray.js'
at Module._resolveFilename (module.js:440:15)
at Function.Module._resolveFilename (C:\Git\stemn-electron-2\node_modules\electron-prebuilt\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (index.js:22:15)
at Module._compile (module.js:541:32)
at loader (C:\Git\stemn-electron-2\node_modules\babel-register\lib\node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Git\stemn-electron-2\node_modules\babel-register\lib\node.js:168:7)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at loadApplicationPackage (C:\Git\stemn-electron-2\node_modules\electron-prebuilt\dist\resources\default_app.asar\main.js:288:12)
at Object.<anonymous> (C:\Git\stemn-electron-2\node_modules\electron-prebuilt\dist\resources\default_app.asar\main.js:330:5)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\david\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start-hot"
npm ERR! node v6.2.1
npm ERR! npm v3.10.6
npm ERR! code ELIFECYCLE
npm ERR! STEMN#0.0.1 start-hot: `cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main/index`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the STEMN#0.0.1 start-hot script 'cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main/index'.
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 STEMN package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main/index
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs STEMN
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls STEMN
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Git\stemn-electron-2\npm-debug.log
It looks like electron is changing the webpack import behavior? These files are imported properly in the renderer windows, just not the main thread...
Have you tried this:
root: [
path.resolve(__dirname)
]
My issue was the I was using webpack to build the electron renderers but not using webpack to build the electron main-thread.
I added a new webpack.config specifically for the main thread - now I can use webpack.root (but all the code must compile now which is a bit of a shame...)