I'm pretty new to Meteor and am getting this error:
=> Errors prevented startup:
While building the application:
lib/packages/iron-router/examples/hooks/hooks.js:30:58: Unexpected token ;
=> Your application has errors. Waiting for file change.
It cropped up with the addition of Iron-Router to my app. The error refers to this file, specifically the line that begins ready: promiseToReady:
this.route('adminPage', {
path: '/admin',
// 10. 3rd party API calls that are similar to waitOns:
waitOn: function() {
return {
// this is made up but I do have code conceptually similar to this
ready: promiseToReady(GoogleApi.call('/foo/bar'));
}
}
});
In Javascript you terminate object params with ,, not with ;.
Incorrect:
return {
ready: promiseToReady(GoogleApi.call('/foo/bar'));
};
Correct:
return {
ready: promiseToReady(GoogleApi.call('/foo/bar')),
};
I also ran into the same problem. Just remove iron-router using mrt/meteor remove iron-router and remove all the directories related to iron-router from packages folder.
Check the directory path from where you are running the mrt/meteor add command...Make sure that you run the command from your project root directory. Running it from project root directory fixed my issue..Earlier I ran the command from one of the sub folder of the project.
It seems the package had installed incorrectly. I made sure to fully delete it and reinstall:
> mrt remove iron-router
> meteor remove iron-router
> mrt add iron-router
> meteor add iron-router
Related
I'm working on migrating a Nuxt.js project from Nuxt#1.4 to 2.7, and after updating the Webpack config as required, etc. I'm now running into the following error.
When I try to access any of the pages on the website, I hit the stock Nuxt loading screen showing bundling progress, which then immediately refreshes ad infinitum. The application never progresses past this screen, and the tab title never changes from Nuxt.js: Loading app....
There are no errors in the console, nor any compile time errors, but when I go to the devtools Network tab, I see a failed (HTTP 500) request to localhost:3000, with the following error as response payload:
NuxtServerError
render function or template not defined in component: NuxtLoading
I looked into NuxtLoading, and the only reference to it I can find is a file in the .nuxt folder called nuxt-loading.vue, which looks like a regular functioning component. It has a render() method, which is implemented as follows:
render(h) {
let el = h(false)
if (this.show) {
el = h('div', {
staticClass: 'nuxt-progress',
class: {
'nuxt-progress-notransition': this.skipTimerCount > 0,
'nuxt-progress-failed': !this.canSucceed
},
style: {
'width': this.percent + '%',
'left': this.left
}
})
}
return el
}
What I've tried:
Reinstall node_modules;
rm -rf .nuxt && yarn dev (EDIT: and yarn.lock);
Upgrading element-ui to latest version.
Thanks in advance for any help. If any more info is needed, please ask.
You have a wrong configuration for i18n loader. It should be like this:
config.module.rules.push({
resourceQuery: /blockType=i18n/,
type: 'javascript/auto',
loader: '#kazupon/vue-i18n-loader'
});
Or you can use nuxt-i18n module, that will setup this for you using vueI18nLoader option.
I've been using Webpack for my ES6 JS project and has been going well until I started to play with dynamic imports.
What I had that worked (router.js):
import { navigo } from "Navigo"; // router
import { clients } from "Controllers/clients.js";
const navigo = new Navigo();
navigo_router.on({
'/clients': () => {
clients.init();
}
});
But the more pages/routes I add, the more imports get stacked up in the head of the module. This is a relatively large app and I have a lot of pages/routes to add and therefore I need to load them dynamically to reduce the size of the initial page load.
So, following Webpack's documentation for dynamic imports, I tried the following which loads the controller module only when the relative route is called:
import { navigo } from "Navigo"; // router
const navigo = new Navigo();
navigo_router.on({
'/clients': () => {
import("Controllers/clients.js").then((clients) => {
clients.init();
});
}
});
But saving this in my editor resulted in a Babel transpiling error; SyntaxError: 'import' and 'export' may only appear at the top level, and clients.init() is not being called when tested in browser.
After a bit of reading, I discovered I needed a Babel plugin to transpile dynamic import() to require.ensure. So, I installed the plugin using the following command:
npm install babel-plugin-dynamic-import-webpack --save-dev
And declared the plugin in my babel.rc file
{ "plugins": ["dynamic-import-webpack"] }
After installing the plugin, the transpiling error disappeared and checking my transpiled code I found that the dynamic import()s has in fact been changed to require.ensure as expected. But now I get the following browser errors when testing:
Error: Loading chunk 0 failed.
Stack trace:
u#https://<mydomain.com>/js/app.bundle.js:1:871
SyntaxError: expected expression, got '<' 0.app.bundle.js:1
Error: Loading chunk 0 failed.
I didn't understand why it was referencing 0.app.bundle.js with the 0. prefix, so I checked my output/dist folder and I now have a new file in there called 0.app.bundle.js:
0.app.bundle.js 1,962bytes
app.bundle.js 110,656bytes
I imagine this new bundled file is the dynamically imported module, clients.js.
I only added dynamic importing to that one route and have left all the other routes as they were. So, during testing, I can view all routes except that one /clients route that now throws the above errors.
I'm totally lost at this point and hoped somebody could help push me over the finish line. What is this new file 0.app.bundle.js and how am I supposed to be using it/including it in my application?
I hope I've explained myself clearly enough and look forward to any responses.
I managed to fix my own problem in the end, so I will share what I discovered in an answer.
The reason the chunk file wasn't loading was because Webpack was looking in the wrong directory for it. I noticed in the Network tab of my developer console that the the chunk file/module was being called from my root directory / and not in /js directory where it belongs.
As per Webpack's documentation, I added the following to my Webpack config file:
output: {
path: path.resolve(__dirname, 'dist/js'),
publicPath: "/js/", //<---------------- added this
filename: 'app.bundle.js'
},
From what I understand, path is for Webpack's static modules and publicPath is for dynamic modules.
This made the chunk load correctly but I also had further issues to deal with, as client.init() wasn't being called and yielded the following error:
TypeError: e.init is not a function
To fix this, I also had to change:
import("Controllers/clients.js").then((clients) => {
clients.init();
});
To:
import("Controllers/clients.js").then(({clients}) => {
clients.init();
});
Note the curly braces in the arrow function parameter.
I hope this helps somebody else.
For debugging, you need to do
import("Controllers/clients.js").then((clients) => {
console.log(clients);
});
maybe working
import("Controllers/clients.js").then((clients) => {
clients.default.init();
});
So here are the details. I'm running the code on a mac. The code was originally built on ubuntu. This wasn't a problem on ember till date.
ERROR -
ENOENT: no such file or directory, lstat
'/Users/...emberapp/tmp/funnel-input_base_path-nz4m8qQr.tmp/index.html'
and below that, this...
Error: ENOENT: no such file or directory, lstat
'/Users/flyn/Documents/working local/backend
dashboard/tmp/funnel-input_base_path-xjJozhFY.tmp/index.html'
at Error (native)
This is the route that's causing the issue. The ajax call works independently when called on browser when running this:
http://localhost:4300/getRecords?by_param=by_usage&include_docs=true&key_type=%20
This is the code on routes.
import Ember from 'ember';
export default Ember.Route.extend({
ajax: Ember.inject.service(), model(){ return
this.get("ajax").request("http://localhost:4300/getRecords", {
data: {
"by_param": "by_usage",
"key_type": "",
"include_docs": true,
"key_value": {}
}
}).then(function(usr) {
// return usr.rows.data;
var ar = []
for (var i=0; i<usr.rows.length; i++){
ar.push(usr.rows[i].doc.data);
}
return ar
});
}
});
Now here's what I did. I removed the ajax call entirely to see if it works after that. It didn't. Then I did (in a very similar naming convention for the route name, with a hyphen -) ...
ember -d route route-name
now it works. Built the route again, added the ajax. It continues working. Close the server and restart, it stops working.
Finally, an additional note.
I saw a similar error on this link
But I already have watchman, which wasn't an issue before, and the first answer (not comment) suggests some ideas, which I'm not sure what that meant.
Thank you
I add a similar issue, have you tried to clear the watchman-list ? it helped me (after a restart of the computer or restart of sublime text) all was working well but sometimes the issue was still there.
I'm trying to load jquery-mockjax into my test suite and followed the instructions on http://www.ember-cli.com/user-guide/#managing-dependencies.
I have placed a Brockfile.js in the root of my ember app:
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
if (EmberApp.env() !== 'production') {
app.import( app.bowerDirectory + '/jquery-mockjax/dist/jquery.mockjax.js', { type: 'test' } );
}
module.exports = app.toTree();
But it seems like the ember CLI is totally ignoring the file - I even tried adding a syntax error to trigger a build error. What could be going wrong?
The Ember CLI as of (1.13) does not actually read the Brocfile.js. But rather ember-cli-build.js.
I solved this issue by having jquery-mockjax in both package.json and bower.json
I have just update iron-router to the latest 0.7.0 and having errors.
Before updating I was using "dev" branch Blaze and everything worked fine.
I have the routes.js in the /lib/router.js so it can load first on both client and server. This is the error I get when I run mrt :
Your app is crashing. Here's the latest log.
/Users/pemmy/.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:173
throw(ex);
^
ReferenceError: Router is not defined
at app/lib/routes.js:1:36
at app/lib/routes.js:79:3
at /Users/pemmy/projects/Meteor/projects/toonokio/.meteor/local/build/programs/server/boot.js:155:10
at Array.forEach (native)
at Function._.each._.forEach (/Users/pemmy/.meteor/tools/c2a0453c51/lib/node_modules/underscore/underscore.js:79:11)
at /Users/pemmy/projects/Meteor/projects/toonokio/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
This is what I have on my router.js file:
1. Router.configure({
2. // layoutTemplate: 'basicLayout',
3. notFoundTemplate: 'notFound',
4. yieldTemplates: {
5. // 'header': { to: 'header' },
6. // 'footer': { to: 'footer' }
7. }
8. });
79. Router.map(function () {
80. this.route('home', {
81. path : '/',
82. controller : HomeController
83. });
84. });
Any suggestions on what am I doing wrong and how to fix it?
Thanks,
Praney
For me, I had this error and the iron-router package was missing from my .meteor/packages file. Replaced it and did a mrt install and it seems to work now.
Tried mrt install and still had the problem.
mrt add iron-router solved it for me.
Follow this answer it may solve your issue:
Meteor: App does not work on 0.9.1.1 version
do meteor remove iron-router and after that meteor add iron:router which solved my problem. suggested by
https://stackoverflow.com/a/25721887/565557