TypeError ... is not a function - gulp

I have installed gulp-run-command as follows:
npm install gulp-run-command
I'm running a series of gulp tasks. All the others work, except this one. Here's the task where I'm running gulp-run-command:
var gulp = require('gulp');
var run = require('gulp-run-command');
gulp.task('testTask', run('testString'));
It is directly from the basic usage of gulp-run-command as shown here:
https://www.npmjs.com/package/gulp-run-command#usage
I get the following error as I run gulp:
TypeError: run is not a function
at Object.<anonymous> (c:\mypath\gulp\tasks\common\initLocalJsonSe
rver.js:6:23)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireDir (c:\mypath\node_modules\require-dir\index.js:123:33)
at requireDir (c:\mypath\node_modules\require-dir\index.js:76:33)
What's wrong here?

Ok, it worked as I added .default at the end of the line: var run = require('gulp-run-command');
So, like this:
var run = require('gulp-run-command').default

Related

Truffle is not compiling neither is it rather gives error "Cannot find module"

Error: Cannot find module 'babel-register'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/mnt/c/Users/acer/blockchain-home/truffle-config.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at Object.require (internal/modules/cjs/helpers.js:25:18)
at Function.load (/home/soyaya/.nvm/versions/node/v10.19.0/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:159:1)
at Function.detect (/home/soyaya/.nvm/versions/node/v10.19.0/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:148:1)
at Object.run (/home/soyaya/.nvm/versions/node/v10.19.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:194:1)
at Command.run (/home/soyaya/.nvm/versions/node/v10.19.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)
Truffle v5.4.10 (core: 5.4.10)
Node v10.19.0
ok i figured it out
in my truffle.config file i edited require('babel-register'); to require('#babel/register');
then i installed babel/register
i edited require('babel-polyfill'); to require('#babel/polyfill');
then i installed babel/polyfill
it worked my truffle passed and compiled
fix this problem by running the following:
npm install -g babel-runtime
You can find the full thread about this truffle bug here:
https://github.com/trufflesuite/truffle/issues/5074

Sequelize model error-tring to make model in sequelize and getting this error

Error 471--cannot find module!
This is the model I am tring to write.T
have data is already in mysql. Tring to connect from sequilize. I deleted all node module and tried again,nothing is working.Please suggest something.
module.exports = function(sequelize,dataTypes) {
var calender = sequelize.define("calender",{
listing_id:DATATYPE.INTEGER,
listdate:DATATYPE.DATE,
available:DATATYPE.TEXT,
price:DATATYPE.TEXT
});
return calender;
};
This is the code
now this is the error
module.js:471
throw err;
^
Error: Cannot find module 'E:\mindsumo\dataairbnb\models/..configconfig.json'
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> (E:\mindsumo\dataairbnb\models\index.js:8:17)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\mindsumo\dataairbnb\server.js:10:11)
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)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
Error while making model
node_modules/.bin/sequelize model:generate --name calender1 --attributes
listing_id:int, listdate:date, available:text, price:text
node_modules/.bin/sequelize model:generate --name calender1 --attributes listing_id:int, lis
tdate:date, available:text, price:text
Sequelize CLI [Node: 6.10.3, CLI: 3.0.0, ORM: 3.30.4]
E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:1079
else throw err
^
TypeError: Cannot read property 'toUpperCase' of undefined
at eval (lodash.templateSources[0]:18:32)
at Array.forEach (native)
at eval (lodash.templateSources[0]:14:26)
at Object.render (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\template-helper.js:26:54)
at Object.generateFileContent
(E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\helpers\model-
helper.js:31:37)
at Object.generateFile (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\model-helper.js:41:49)
at Object.exports.handler (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\commands\model_generate.js:32:27)
at Object.self.runCommand (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\lib\command.js:233:22)
at Object.Yargs.self._parseArgs (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:990:30)
at Object.get [as argv] (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:927:19)
at Object.<anonymous> (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\sequelize:84:15)
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)
E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\node_modules\yargs\yargs.js:1079
else throw err
^
If you used Express framework, this example help you a lot:
https://github.com/sequelize/express-example/tree/master/models
I too had problems with Sequelize in the start.
Check especially:
models/index.js
models/user.js
routes/index.js

Mean.io application is throwing error with forever

I am working on a mean.io application. I am trying to run this application on Ubuntu shell with forever module of node but it is throwing an error
"util.js:756
throw new TypeError('The super constructor to `inherits` must not ' +
^: The super constructor to `inherits` must not be null or undefined.
at Object.exports.inherits (util.js:756:11)
at Object.<anonymous> (/usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:142:7)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/lib/node_modules/forever/node_modules/forever-monitor/lib/index.js:14:24)
at Module._compile (module.js:435:26)
"
Can anyone help on this what is the actual issue,how i can resolve this error.
I have faced the same issue. It was due to using Redistore with "express" parameter
var RedisStore = require('connect-redis')(express);
finally I fixed it using a session as parameter.
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
Hope it helps you.

JSON.parse failing if i pass ISODate

I have the below sample code which is failing if i pass ISODate in JSON object
var data =[{"$match":{"CREATED_DATE":{"$gt":ISODate("2015-07-29T17:30:00.000Z"),"$lt":ISODate("2015-07-30T09:00:00.000Z")}}}]
var update=JSON.parse(data);
Below is the error
/home/ubuntu/rr.js:1
name) { var data =[{"$match":{"EPS_TRANSACTION.CREATED_DATE":{"$gt":ISODate("2
^
ReferenceError: ISODate is not defined
at Object.<anonymous> (/home/ubuntu/rr.js:1:123)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I am unable to handle the error,any solution will be much helpful

node.js fnoc module gives error -- probably something simple

I'm sure I'm doing something stupid, but I can't get node-fnoc to work. I have a directory with a simple package.json in it, I have a /config/ directory in that directory with a simple JSON file in it. And, I'm basically just trying to do what they have in their example.
var fnoc = require('fnoc');
fnoc(function(err, configs){
console.log(configs);
});
and this is what I'm getting:
fnoc(function(err, configs){
^
TypeError: object is not a function
at Object.<anonymous> (/opt/backups/readconfig.js:3:1)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Any ideas?
The document on github is for version 0.2.2
You need to install fnoc#0.2.2
npm install fnoc#0.2.2
Run your js
node your.js
Output:
{ package:
{ name: 'asdf',
dependencies:
{ express: '*',
jade: '*',
Version is in the changelog file:
https://github.com/jprichardson/node-fnoc/blob/master/CHANGELOG.md