Angular.js: Bug : TypeError: Attempted to assign to readonly property.

Created on 10 Oct 2017  Â·  3Comments  Â·  Source: angular/angular.js

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] other (Please do not submit support requests here (see above))

Current behavior:

PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  TypeError: Attempted to assign to readonly property.
  at node_modules/angular-mocks/angular-mocks.js:18

Expected / new behavior:

I'm currently using Ubuntu 16.04 with virtualenv, this error makes it unable to run my frontend server. Which is making it difficult to work on the backend.

Minimal reproduction of the problem with instructions:

running.
gulp dev:runserver

Whole error

[18:25:34] Using gulpfile ~/OpenSource/evalai/gulpfile.js
[18:25:34] Starting 'dev:runserver'...
[18:25:34] Starting 'dev'...
[18:25:34] Starting 'clean'...
[18:25:34] Finished 'clean' after 50 ms
[18:25:34] Starting 'css'...
[18:25:34] Starting 'js'...
[18:25:34] Finished 'js' after 26 ms
[18:25:34] Starting 'html'...
[18:25:34] Finished 'html' after 1.96 ms
[18:25:34] Starting 'images'...
[18:25:34] Starting 'vendorjs'...
Required path doesn't exist: /home/isht3/OpenSource/evalai/bower_components/angular-material-datetimepicker/dist/angular-material-datetimepicker.min.js angular-material-datetimepicker
[18:25:34] Finished 'vendorjs' after 895 μs
[18:25:34] Starting 'vendorcss'...
Required path doesn't exist: /home/isht3/OpenSource/evalai/bower_components/angular-material-datetimepicker/css/material-datetimepicker.css angular-material-datetimepicker
[18:25:34] Finished 'vendorcss' after 430 μs
[18:25:34] Starting 'fonts'...
[18:25:34] Starting 'configDev'...
[18:25:34] Finished 'configDev' after 4.82 ms
[18:25:34] Finished 'fonts' after 222 ms
[18:25:34] Finished 'images' after 232 ms
[18:25:34] Finished 'css' after 576 ms
[18:25:34] Starting 'inject'...
[18:25:34] Finished 'inject' after 4.73 ms
[18:25:34] Finished 'dev' after 634 ms
[18:25:34] Starting 'lint'...
[18:25:35] gulp-inject 9 files into base.html.
[18:25:36] Finished 'lint' after 1.56 s
[18:25:36] Starting 'connect'...
[18:25:36] Finished 'connect' after 17 ms
[18:25:36] Starting 'watch'...
[18:25:36] Finished 'watch' after 135 ms
[18:25:36] Starting 'test:watch'...
[18:25:36] Server started http://localhost:8888
10 10 2017 18:25:36.655:WARN [watcher]: Pattern "/home/isht3/OpenSource/evalai/frontend/dist/vendors/*.js" does not match any file.
10 10 2017 18:25:36.696:WARN [karma]: No captured browser, open http://localhost:9876/
10 10 2017 18:25:36.705:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
10 10 2017 18:25:36.705:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
10 10 2017 18:25:36.730:INFO [launcher]: Starting browser PhantomJS
10 10 2017 18:25:37.024:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket JifOUk5oAkoB3DrkAAAA with id 22967302

START:
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  TypeError: Attempted to assign to readonly property.
  at node_modules/angular-mocks/angular-mocks.js:18

Finished in 0.143 secs / 0 secs @ 18:25:37 GMT+0530 (IST)

SUMMARY:
✔ 0 tests completed

I searched a lot, I found nothing on how I could solve it. I'm new to angular.

ngMock more info

All 3 comments

What version of AngularJS are you using? What is on node_modules/angular-mocks/angular-mocks.js line 18 (that is mentioned in the stack trace)?

This is a big guess as you have not provided enough information to be certain but I believe the line where you are getting the error is

angular.mock = {};

which implies that angular.mock is a readonly property or possibly that angular does not exist. In the latter case I am guess that the error message is a red-herring?

If this is the case then it may be that you have not loaded the angular.js file before loading the angular-mocks.js file?

@gkalpak @petebacondarwin I don't know what was exactly going wrong, I don't have enough debugging experience on Angular, but it was solved when I ran bower install angular-material-datetimepicker. I saw a few issues on this in the past, hope this helps whoever comes across this error.

Was this page helpful?
0 / 5 - 0 ratings