Trying to convert react application to next application - next.js

Keep getting error
SyntaxError: Cannot use import statement outside a module
cyberoni_next\node_modules\three\examples\jsm\lines\LineGeometry.js:2
import { LineSegmentsGeometry } from "../lines/LineSegmentsGeometry.js";
In node modules?? really confused.
import { LineSegmentsGeometry } from "../lines/LineSegmentsGeometry.js";

Related

VueFire with vite

Hi i'm using vuefire with vite when i try to
import { VueFire, VueFireAuth } from 'vuefire'
I get this error :
Uncaught SyntaxError: Function statements require a function name (at chunk-TZOYARRL.js?v=786f7321:13756:9)

Collection is not defined after a bare meteor install on windows 10

This newly installed meteor (1.10.2) by chocolatey on windows 10 followed by meteor create --bare appName then copy/paste some 2 year old code I had parked for a while. Chassing the cause of this runtime error for no avail.
ReferenceError: DataTeckCol is not defined
at server/dataTeck.js:13:1
at module (server/dataTeck.js:20:8)
../server/dataTeck.js
"use strict";
let cheerio = require('cheerio');
import {Matcher} from "./matcher";
import {Dispatcher} from "./dispatcher";
import '../imports/api/dataTeck.js';
DataTeckCol.remove({plateNum: {$in: plates}}); //<<<<<<<< Error line
../imports/api/dataTeck.js
import { Mongo } from 'meteor/mongo';
export const DataTeckCol = new Mongo.Collection('dataTeckCol');
You need to explicitly import the exported const, so instead of
import '../imports/api/dataTeck.js';
you need to import it via
import { DataTeckCol } from '../imports/api/dataTeck.js';

How to import redux-logger?

I'm trying to import redux logger v.3.0.6. https://github.com/evgenyrodionov/redux-logger
Attempt 1
import logger from 'redux-logger';
error
Uncaught SyntaxError: The requested module '../node_modules/redux-logger/dist/redux-logger.js' does not provide an export named 'default'
Attempt 2
import { logger } from 'redux-logger';
error
Uncaught SyntaxError: The requested module '../node_modules/redux-logger/dist/redux-logger.js' does not provide an export named 'logger'
Attempt 3
import { createLogger } from 'redux-logger';
error
Uncaught SyntaxError: The requested module '../node_modules/redux-logger/dist/redux-logger.js' does not provide an export named 'createLogger'
The third one is the one suggested on the github page. How do I solve this?
I had the same issue and solved it like this:
import createLogger from 'redux-logger';
// ...
const loggerMiddleware = createLogger;
It seems createLogger is a default export.
I am using like your first attempt and it is working fine,
import logger from "redux-logger";
I am also using the same version - 3.0.6 for both typings and logger itself.
"#types/redux-logger": "^3.0.6",
"redux-logger": "^3.0.6",
This suggestion was given to me in the error i got after installing and importing redux-logger.
the fix i found out is given below.
import pkg from "redux-logger";
const {createLogger}=pkg;
const logger=createLogger()
hope it helps!!

Client-side Loggly Meteor 1.4.1

I'm trying to setup some kind of logging for my meteor app and chose Loggly, I read this article, but I can't get the client-side implementation to work.
// in startup/client/loggly-client.js
import { Meteor } from 'meteor/meteor';
import { winston } from 'meteor/clinical:winston-browser-logging';
winston.info("winston-client has started on the client!");
// in startup/client/index.js
import './loggly-client.js';
import './routes.js';
Error I'm getting is Uncaught TypeError: Cannot read property 'info' of undefined
According to https://github.com/clinical-meteor/winston-browser-logging/blob/master/package.js it should be Winston, not winston.

Collection.insert is not a function - Meteor

Good day developers! I'm working with Meteor.js it's my 1st expirience
I created collection in file
// ./dbs/messages.js
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export const Messages = new Mongo.Collection('messages');
and use it in api point with calling Messages.insert like that
// server/mail.js
import Messages from './dbs/messages.js';
Meteor.methods({
'message.post'(messageText, location){
Messages.insert({
messageText: messageText,
location: location
});
}
})
But when I call 'message.post' I get an error
Exception while invoking method 'message.post' TypeError
Messages.insert is not a function
BUT, when I comment collection import and declare it in server/main.js like that
// import Messages from './dbs/messages.js';
const Messages = new Mongo.Collection('messages');
Meteor.methods({
'message.post'(messageText, location){
Messages.insert({
messageText: messageText,
location: location
});
}
});
In this case my Messages.insert works properly.
Who has experience with Meteor - can you explain me what is the reason?
Thanks!
Also I have removed autopublish and insecure packages
As #MasterAM and #Ankur Soni said you need to import Messages using brackets import { Messages } from './dbs/messages.js';
The only way to import without brackets is by defining Messages and then exporting it like so export default Messages;
I initiate my collections in a "common" space. I feel what you did is actually right. You either declare the collection twice, once on the client side and once on the server side or do it only once in a common folder. I see in many documentations that the popular place to keep these declarations is the /imports/api ... which is common to both server and client.
Rgs,
Paul

Resources