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?
Related
I am working in node Js. When im trying to load a file, with this lines:
key: fs.readFileSync('./localCerts/local.dev.key'),
cert: fs.readFileSync('./localCerts/local.dev.crt'),
This is error appeards when I try to rub application:
bou-frontend#0.0.1 start /Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend
node src/index.js
fs.js:114
throw err;
^
Error: ENOENT: no such file or directory, open
'/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/build/index.html'
at Object.openSync (fs.js:438:3)
at readFileSync (fs.js:343:35)
at Object. (/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/src/ssr.js:34:22)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bou-frontend#0.0.1 start: node
src/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
bou-frontend#0.0.1 start script. npm ERR! This is probably not a
problem with npm. There is likely additional logging output above.
PACKAGE.json file:
scripts": {
"start": "node src/index.js",
}
Any advice or help is welcome.
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
===============================================================
While starting my application, I get this error. I have already checked and seen that the required module is well installed, and also gave it global access.
Hussains-MacBook-Pro:NodeRest-Shop Hussain$ npm start
> noderest-shop#1.0.0 start /Users/Hussain/Desktop/Development/Web/NodeRest-Shop
> nodemon server.js
module.js:549
throw err;
^
Error: Cannot find module 'binary-extensions'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Hussain/Desktop/Development/Web/NodeRest-Shop/node_modules/is-binary-path/inde
x.js:3:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! noderest-shop#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the noderest-shop#1.0.0 start 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! /Users/Hussain/.npm/_logs/2018-06-25T05_23_59_594Z-debug.log
You're missing the binary-extensions module, as seen in your log:
Error: Cannot find module 'binary-extensions'
It could be that you're missing some dependencies or forgot to include it.
You can install it using npm:
npm install binary-extensions
And include binaryExtensions in your project:
const binaryExtensions = require('binary-extensions');
I fixed this issue by running:
npm i npm#latest -g
Check your app.js file your index route should be
app.use(require('./routes/')); not app.use(require('./routes/index'));
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.
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?