process.nextTick is not a function (React native, ddp, meteor) - meteor

On react native, I am trying to use 'ddp-client' node library to connect to a meteor server. Just after the connection is successful, I am getting the following ERROR on client side:
2016-01-17 16:14:15.992 [trace][tid:com.facebook.React.JavaScript] ddp message: {"msg":"connected","session":"PGLBqgvoeuXgBtke2"}
2016-01-17 16:14:16.007 [warn][tid:com.facebook.React.JavaScript] process.nextTick is not a function. (In 'process.nextTick(function(_this){
return function(){
return _this._flush();};}(
this))', 'process.nextTick' is undefined)
2016-01-17 16:14:16.008 [error][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: process.nextTick is not a function. (In 'process.nextTick(function(_this){
return function(){
return _this._flush();};}(
this))', 'process.nextTick' is undefined)

process.nextTick doesn't exist on React Native so we've got to polyfill it. That is as simple as process.nextTick = setImmediate.
Example: https://github.com/spencercarli/meteor-todos-react-native/blob/master/ReactNativeTodos/app/config/db/lib/process.polyfill.js
You'll want to make sure you do this in your root component file (eg index.ios.js)
Hope this helps you!

I've come across the same problem, but #Spencer Carli's answer is not perfect, in debugging mode, shimming nextTick is not only unnecessary (js runs in v8 when debugging), it will also make your app failed to connect the development server (I don't know why, but it actually does). So the more suitable answer is:
if (!__DEV__) {
global.process.nextTick = setImmediate
}

You can also use react-native-meteor package for React Native Meteor integration.
https://www.npmjs.com/package/react-native-meteor check this link for documentation.

Related

Meteor 1.9 build broken with rollup enabled

I'm getting following error in my Angular Meteor project:
TypeError [ERR_INVALID_ARG_VALUE] [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '\u0000commonjs-proxy:/builds/intemp/in-pool/node_modules/core-js/internals/package.json'
at readFile (fs.js:295:10)
at go$readFile (/home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:110:14)
at Object.readFile (/home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:107:12)
at next (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:98:12)
at load_shims (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:116:7)
at resolve (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:236:5)
at /home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:66:5
at new Promise (<anonymous>)
at Object.resolveId$1 [as resolveId] (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:63:11)
at resolveId (packages/angular-typescript-compiler/rollup.js:52:26)
at /home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup/src/utils/first.js:8:31
at /home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/fiber_pool.js:43:40 {
code: 'ERR_INVALID_ARG_VALUE'
}
I'm running following command to build:
METEOR_DISABLE_OPTIMISTIC_CACHING=1 ROLLUP=1 AOT=1 BABEL_CACHE_DIR=/tmp meteor build ../output
without rollup it works, and it also worked before Meteor 1.9
Does anyone have any ideas how to resolve this?
I don’t think rollup=1 has ever worked properly in the angular-meteor compilers. I vaguely remember ardatan mentioning it in a github issue but can’t locate the exact one. The documentation still states it as an option but I think you should forget about it unless you want to fix the specific compiler issue.
Meteor 1.9 is a big upgrade as it uses node 12 so I would not be surprised if this has introduced an issue in the angular compilers package. It probably needs a few tweaks to bring it up to date.

error using Meteor upload

i followed the Meteor Upload guide exactly , but i get this error when i load my uploading template.
any clues ?
Exception from Tracker recompute function: Cannot read property 'autoStart' of null
TypeError: Cannot read property 'autoStart' of null
at Template.upload.created (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/tomi_upload-jquery.js?b6bf3c0cc365d2eb8f9acc93ee3dcc4bfd892687:2569:29)
at null.<anonymous> (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2995:20)
at fireCallbacks (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1835:16)
at Object.Tracker.nonreactive (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:513:12)
at http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1832:13
at Object.Blaze._withCurrentView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
at Object.Blaze._fireCallbacks (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1831:9)
at Object.Blaze._createView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1849:9)
at Object.Blaze._materializeView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1853:9)
I've just tested it with Meteor for Windows and it works perfect for me.
Meteor.startup(function () {
UploadServer.init({
tmpDir: process.env.PWD + '/.uploads/tmp',
uploadDir: process.env.PWD + '/.uploads/',
checkCreateDirectories: true
})
});
Check what you are getting at process.env.PWD, I think issues comes from your enviroment. You need write permissions to that path. Also check out latest updates with meteor update.
Btw, it can be issue with nitrous enviroment.

meteor Uncaught ReferenceError: Tracker is not defined

I'm getting the following error - Uncaught ReferenceError: Tracker is not defined
I am running meteor under windows(meteor version 0.8.3).
The code is in my templates js file.
Tracker.autorun(function (c) {
if (MovieTrailers.find().fetch().length == 0)
return;
c.stop();
PlayCurrentTrailer();
});
So far I have tried :
meteor add deps
But that didn't work.
Is tracker available under 0.8.3? or am I missing a package?
tracker is the new name of deps, so replace the occurrence of tracker in your code with deps and you're good to go.
Try to avoid running older versions of Meteor to develop new code, can't you run a VM or use an online service like Nitrous.io for development purpose, as deploying a Meteor app to production in a Windows environment for the moment is not going to happen anytime soon ?

Grunt : JASMINE is not supported anymore

i created an angular application with yeoman, when i executed grunt command i got the following error
Running "karma:unit" (karma) task
WARN [config]: JASMINE is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: JASMINE_ADAPTER is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: LOG_INFO is not supported anymore.
Please use `karma.LOG_INFO` instead.
ERROR [config]: Config file must export a function!
module.exports = function(config) {
config.set({
// your config
});
};
how do i solve this error ?
It's just those two predefined terms (JASMINE and JASMINE_ADAPTER)
that should not be used any more. All you have to do is open the
config file ./config/karma.conf.js and comment out those terms and add
frameworks = ["jasmine"];.
Via Yasuhiro Yoshida
apart from #sheplu's answer, there are additional changes that need to be done in karma.conf.js, you can see it in https://gist.github.com/sivakumar-kailasam/6421378
this gist solves your problem of 'Config file must be a export a function!'
The official docs has these changes as well http://karma-runner.github.io/0.10/config/configuration-file.html

Meteor: EJSON is not defined

I'm trying to use a private JSON file to add some simple template documents to the mongo collection if it is empty:
if (Passions.find().count() === 0) {
mockPassions = JSON.parse(Assets.getText("mockups/passions.json"));
_.each(mockPassions.passions, function(passion) {
return Passions.insert(passion);
});
}
I'm getting the error:
ReferenceError: EJSON is not defined
Does anyone have any clue? I'm using Meteor 0.6.5.
Thanks
You need to bring EJSON up to the global namespace via
meteor add ejson
In meteor 0.6.5 unless you explicitly tell it to, packages are namespaced into package
Considering Latest Meteor 1.6, you can follow below steps:
A. First Approach [Independent of the meteor restart/stop/start]
Edit .meteor/packages file and add 'ejson' to end of the file
B. Second Approach
Stop Server if already running by pressing ctrl+c
Run command meteor add ejson
Restart Server using command meteor

Resources