Ошибка cannot read property prototype of undefined

I have a little problem. I’m using backbone.js. I wrote this code like in example:

<script>
$(document).ready(function () {
    window.App = {
        Views: {},
        Models: {},
        Collections: {}
    }

    App.Collections.Users = Backbone.Collection.extend({
         model: App.Models.User,
         url: 'service'
    });
    App.Models.User = Backbone.Model.extend({});

    App.Views.App = Backbone.View.extend({
         initialize: function() {
             console.log( this.collection.toJSON() );
         }
    });

});
</script>

Than I started server and in browser console type this:

var x =new App.Collections.Users();
x.fetch()

And this follows to error: Uncaught TypeError: Cannot read property 'prototype' of undefined. But data is present in response. Details in picture. How to fix this?
Thanks for you answers.enter image description here

enter image description here

asked Oct 31, 2013 at 9:33

Oleksandr H's user avatar

Oleksandr HOleksandr H

2,96510 gold badges40 silver badges57 bronze badges

I fixed this bug. The problem was that I created Collection and then the Model. Collections use user model, as working unit, but when I defined this Collection, I did not define Model.

So, if you want to avoid this bug, firstly define a Model and only then define the Collection.

DJG22's user avatar

DJG22

1,7463 gold badges34 silver badges65 bronze badges

answered Oct 31, 2013 at 10:15

Oleksandr H's user avatar

Oleksandr HOleksandr H

2,96510 gold badges40 silver badges57 bronze badges

6

Backbone Js has dependency with underscore.js and jQuery, try reordering the resources.
This worked for me:

<head>
    <title>Backbone</title>

    <!-- Scripts Load Here-->       
    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="js/underscore.js"></script>
    <script type="text/javascript" src="js/backbone.js"></script>
</head>

answered May 24, 2014 at 5:51

rzskhr's user avatar

rzskhrrzskhr

90111 silver badges9 bronze badges

2

In my case , imports were incorrect

import { urlencoded } from "express";
When I removed this statement , it worked for me.
Check imports of the files you are working with , wheteher something unnecessary imported

answered May 27, 2021 at 11:03

vishal dange's user avatar

In my case, the following imports are incorrect: (react)

// remove
import e from 'express';

answered May 8, 2021 at 9:03

niek tuytel's user avatar

niek tuytelniek tuytel

8797 silver badges18 bronze badges

Answer by Stephanie Patrick

Cannot read property ‘prototype’ of undefined,Uncaught TypeError: Cannot read property ‘prototype’ of undefined,

Is there a term for the letter T not being pronounced when at the end of a word?

item.ts:

export class Item {
    myAwesomeFunction() {
        ...
    }
}

index.ts (to be able to reference smoothly):

...
export * from './item';
...

other.item.ts:

import { ..., Item, ... } from './index';

export class OtherItem extends Item ... {
    ...
}

After changing other.item.ts to the following, it worked:

import { ... } from './index';
import { Item } from './item';

export class OtherItem extends Item ... {
    ...
}

Answer by Derrick Hunter

Backbone Js has dependency with underscore.js and jQuery, try reordering the resources.
This worked for me:

<head>
    <title>Backbone</title>

    <!-- Scripts Load Here-->       
    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="js/underscore.js"></script>
    <script type="text/javascript" src="js/backbone.js"></script>
</head>

Answer by Matteo Hickman

To any one who get into this problem (common.js:48 Uncaught TypeError: Cannot read property ‘prototype’ of undefined) from Google .,TypeError: Cannot read property ‘prototype’ of undefined
i have this error ,please let me know we having the problem?,For «prototype of undefined» like errors, please try to fetch an api key from google: https://developers.google.com/maps/documentation/javascript/

         new GMaps({
            div: '#gmap',
            lat: -12.043333,
            lng: -77.028333
        });

Answer by Zakai Benson

I get an Uncaught TypeError when displaying a page. It says:
,
#3065062: Getting «Uncaught TypeError: Cannot read property ‘prototype’ of undefined» ,
#3065149: Uncaught TypeError: Cannot set property ‘Bridge’ of undefined

I tried to alert('Hey') in docroot/themes/contrib/bootstrap/js/misc/ajax.js before findGlyphicon like below but couldn’t see anything.

   alert("Hello! I am an alert box!!");
  Drupal.Ajax.prototype.findGlyphicon = function (element) {
    return $(element).closest('.form-item').find('.ajax-progress.glyphicon')
  };

Answer by Layne Morrison

ourcodeworld.com is using a security service for protection against online attacks. This process is automatic. You will be redirected once the validation is complete. , Please enable cookies on your browser and try again.

More Details Refer


Answer by Jasiah Green

More Details Refer


Answer by Kaleb Perkins

import response from { ‘express’ },I found the I have mistakenly typed,I found that this problem happens when you try to call backEnd stuff in your frontEnd.
when I delete that line problem solved.

I found the I have mistakenly typed

import response from { 'express' }

import response from { 'express' }

Answer by Thea Palmer

I Have the following error when i execute «node app» coomand,
TypeError: Cannot read property ‘prototype’ of undefined
,same issue, you need to upgrade the project code for latest node and socket.io version

More Details Refer


Answer by Lana Lucas

TreeGrid control v17.1.39, after production build — Cannot read property ‘prototype’ of undefined

More Details Refer


Answer by Annalise Bishop

I’ve got this error : Cannot read property ‘prototype’ of undefined
,
I’ve got this error : Cannot read property ‘prototype’ of undefined ,
google-chrome-extension

More Details Refer


Answer by Dario Arroyo

“TypeError: Cannot read property ‘prototype’ of undefined” in _extends method.,It seems the TS compiler misordered the subclass before the base class so that the this error happens.,Thanks! I verified the generated js code, the subclass is indeed decleared before the base class.

This compiled code will throw a ReferenceError exception by native javascript engine if Class syntax is implemented. It means that TS...

🐛 Bug Report

I was trying to mock redis module using jest.mock('redis'). The test failed with following error

TypeError: Cannot read property 'prototype' of undefined

      at Object.<anonymous> (node_modules/redis/lib/individualCommands.js:26:13)
      at Object.<anonymous> (node_modules/redis/index.js:1102:1)

To Reproduce

Steps to reproduce the behavior:

  1. install redis npm i redis@2.8.0
  2. create a test file mocking-redis.test.js with following content
jest.mock('redis');
const redis = require('redis');

describe('Tests', () => {
	test('test1', () => {
		expect(true).toEqual(true);
	});
});

Expected behavior

redis should be mocked and test should pass successfully

Link to repl or repo (highly encouraged)

https://github.com/Amit-Modi/jest-mocking-experiments

envinfo

npx: installed 1 in 1.136s

  System:
    OS: macOS Mojave 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    npm: 6.9.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0

Discover why this exception appears when using Vue Bootstrap in Vue.js 3.

In the last days I applied for a new job where Vue.js was a requirement to apply, in order to get in, I needed to present a test to design a dashboard with Bootstrap Vue.

While trying to set up a new project, the CLI offered me the possibility to work With Vue 2 and Vue 3 so I decided to go on with the latest version (Vue 3). After reading the documentation, getting comfortable with the way Vue.js works, I started to create some components and they work as expected. When I was ready to start with the bootstrap library, after the installation and after trying to import the library as it theoretically should:

// main.js
import App from './App.vue'
import { createApp } from 'vue'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

// Install BootstrapVue
App.use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
App.use(IconsPlugin)

createApp(App).mount('#app')

When trying to build the project, the following exception will appear on the terminal:

config.js?228e:8 Uncaught TypeError: Cannot read property 'prototype' of undefined
    at eval (config.js?228e:8)
    at Module../node_modules/bootstrap-vue/esm/utils/config.js (chunk-vendors.js:3251)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (alert.js?5fda:1)
    at Module../node_modules/bootstrap-vue/esm/components/alert/alert.js (chunk-vendors.js:83)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (index.js?cca8:1)
    at Module../node_modules/bootstrap-vue/esm/components/alert/index.js (chunk-vendors.js:95)

This problem doesn’t have solution till the date as Bootstrap Vue doesn’t provide support for Vue 3 yet, however it seems that the support will arrive to production soon.

  • Vue 3 Support will arrive soon

Solution

For now, I hope that you are starting a project from scratch as I did because you will need to downgrade your Vue.js project from version 3 to Vue.js 2.

Happy coding ❤️!

After installing Redis in our server as outlined in my last post on installation of Redis in CentOS 6.5, it was time for me to setup ExpressJS-NodeJS-Redis(Session Store) setup for the webapp that I am working on.

Everthing seemed perfect until I attempted to start the node server using the command: node app.js. I was welcomed with the below error message which highlighted the fact that connect-redis npm module had falied to connect to my Redis server.

var redis_store = require('connect-redis')(express);
TypeError: Cannot read property 'prototype' of undefined
    at module.exports (/home/nodeuser/node_modules/connect-redis/lib/connect-redis.js:96:41)
    at repl:1:43
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

Upon scouting Internet for answers, the solution posted by Andrei Karpushonak at StackOverflow post titled, ‘RedisStore – TypeError: Cannot read property ‘prototype’ of undefined‘ solved the issue.

Since I have used expressjs version 3.4.8 in my application, I had to use a compatible connect-redis npm. As per the StackOverflow post, the version mentioned by Andrei Karpushonak is 1.4.7.

I installed connect-redis-1.4.7 using the command: npm install --save connect-redis@1.4.7 and the webapp started without reporting any failures.

Возможно, вам также будет интересно:

  • Ошибка canon загрузите бумагу ltr
  • Ошибка cannot read property msie of undefined
  • Ошибка cannot read property createobjectasync of undefined спутник
  • Ошибка cannot read property createobjectasync of undefined как исправить
  • Ошибка cannot read property add of undefined

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии