Nodejs version : 4.4.7
NPM version: 2.15.8
I am running the following code, which is literally copied from the following URL
https://kafka.js.org/docs/getting-started
const { Kafka } = require('kafkajs')
const kafka = new Kafka({
clientId: 'my-app',
brokers: ['kafka1:9092', 'kafka2:9092']
})
The above code is saved in "apps.js" file under a "simpleapp" folder. In addition to that I have installed the following
npm install kafkajs
When I run the app.js file I get the following error
/Users/nick/Documents/nodeprojects/simpleapp/apps.js:1
(function (exports, require, module, __filename, __dirname) { const { Kafka } = require('kafkajs')
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
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 Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
What is the issue?
Version 4.4.7 of NodeJS is very old, and isn't even supported anymore. KafkaJS follows the same support schedule as NodeJS itself, so the oldest currently supported version is 8.
Related
I'm using laravel elixir and gulp to compile my sass files. but when i write gulp in termial I get this error.
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (/home/user/Videos/projetct-folder/project/node_modules/natives/index.js:143:24)
at Object.req [as require] (/home/user/Videos/projetct-folder/projetct/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/home/user/Videos/projetct-folder/projetct/node_modules/laravel-elixir-livereload/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
Node version: 12.4.0
gulp CLI version: 2.2.0
gulp Local version: 4.0.2
gulpfile.js:
var elixir = require('laravel-elixir');
require('laravel-elixir-livereload');
elixir.config.assetsPath = 'themes/project/assets/';
elixir.config.publicPath = 'themes/project/assets/compiled/';
elixir(function(mix){
mix.sass('agency.scss');
mix.scripts([
'jqBootstrapValidation.js',
'agency.js',
'contact_me.js',
'recherche.js'
]);
mix.livereload([
'themes/project/assets/compiled/css/agency.css',
'themes/project/**/*.htm',
'themes/project/assets/compiled/js/*.js'
])
})
Judging by this bug report for Gulp, it's possible that one of the dependencies is using Gulp 3
one of the packages in your project is likely to be requiring gulp 3. If you inspect your package-lock.json which contains the list of installed packages, you should be able to sort it out.
It specifically mentions the graceful-fs module.
i am trying execute test with jest in CRA and i keep getting this weird error.
C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\auth0-js\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import
Authentication from './authentication';
^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Object.require.extensions.(anonymous function) [as .js]
(C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\babel-register\lib\node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
any ideas on how to fix this?
thanks
If you see this error, your EF6 import statements are not being transpiled. Make sure your babel presets contain "env"
.babelrc and "babel" property in package.json
{
"presets":["env", "react"]
}
Depending on your use case you might also need to add the transform-es2015-modules-amd plugin, more here.
I have just updated my Polymer development tools and I get some errors, although everything was working fine before. Here is what I get when trying 'yo polymer' in the console :
/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444
this.env.sharedFs.on('change', writeFiles);
^
TypeError: Object # has no method 'on'
at run (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444:21)
at Environment.run (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:330:20)
at /usr/lib/node_modules/yo/lib/cli.js:91:9
at Environment.resolver.lookup (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:50:12)
at init (/usr/lib/node_modules/yo/lib/cli.js:66:7)
at pre (/usr/lib/node_modules/yo/lib/cli.js:53:3)
at Object. (/usr/lib/node_modules/yo/lib/cli.js:155:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Or when I type 'yo' in the console and choose 'polymer' :
/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:9379
throw e;
^
TypeError: Object # has no method 'on'
at run (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:444:21)
at Environment.run (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:330:20)
at module.exports (/usr/lib/node_modules/yo/lib/routes/run.js:20:11)
at Router.navigate (/usr/lib/node_modules/yo/lib/router.js:36:30)
at PromptUI.completed (/usr/lib/node_modules/yo/lib/routes/home.js:76:20)
at PromptUI.onCompletion (/usr/lib/node_modules/yo/node_modules/inquirer/lib/ui/prompt.js:69:10)
at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1965:12)
at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1902:14)
at AutoDetachObserverPrototype.completed (/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:9397:23)
at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted >(/usr/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.all.js:1902:14)
Any idea on what when wrong with the updates (no error thrown).
Thanks for reading and all the best.
PS : I am running on
Fedora 20
npm 2.5.1
yo 1.4.5
generator-polymer 0.7.0
gem 2.1.11
sass 3.4.12
compass 1.0.3
Update yo (npm install -g yo). I had the same problem.
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
I have installed this database plugin for Node.js called 'db-mysql' and I've gone through all the steps mentioned on the site without getting errors, which must mean that the plugin is installed. But when I run my .js file (given below) in the Apache server I get this error.
Error: Cannot find module 'db-mysql'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/var/www/server.js:4:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Here is the sample code I'm running.
var http = require("http");
var mysql = require("db-mysql");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
//Database Connectivity//
new mysql.Database({
hostname: 'localhost',
user: 'root',
password: '',
database: 'test'
}).on('error', function(error) {
console.log('ERROR: ' + error);
}).on('ready', function(server) {
console.log('Connected to ' + server.hostname + ' (' + server.version + ')');
}).connect();
///////////////////////
response.end();
}).listen(8889);
Did I miss anything during installation?
If you install module like in example
npm install db-mysql
Node will search it here
./project_root/node_modules/db-mysql
So make sure this path is correct in your case.
Other option is to install it globally by using -g flag
npm install db-mysql -g
Simply make a sym link that points to where your modules are physically installed
Name this link node_modules and put it inside the folder of your project