question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'this' keyword is equivalent to 'undefined'

See original GitHub issue

Env “svelte-i18n”: “^2.1.1” “sapper”: “^0.27.0”, “svelte”: “^3.0.0”

Describe the bug Adding the following shows trail of debug logs within the console.

//i18n.js
import { register, init } from 'svelte-i18n';

Logs

console log

sapper dev

✔ server (1.8s) • client The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __extends = (this && this.__extends) || (function () { ^ 2: var extendStatics = function (d, b) { 3: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __extends = (this && this.__extends) || (function () { ^ 2: var extendStatics = function (d, b) { 3: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 12: }; 13: })(); 14: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 15: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 16: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 12: }; 13: })(); 14: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 15: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 16: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __assign = (this && this.__assign) || function () { ^ 7: __assign = Object.assign || function(t) { 8: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __assign = (this && this.__assign) || function () { ^ 7: __assign = Object.assign || function(t) { 8: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 7: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 8: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 7: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 8: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 7: // tslint:disable:no-consecutive-blank-lines 8: // tslint:disable:align 9: var __extends = (this && this.__extends) || (function () { ^ 10: var extendStatics = function (d, b) { 11: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 7: // tslint:disable:no-consecutive-blank-lines 8: // tslint:disable:align 9: var __extends = (this && this.__extends) || (function () { ^ 10: var extendStatics = function (d, b) { 11: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 20: }; 21: })(); 22: var __assign = (this && this.__assign) || function () { ^ 23: __assign = Object.assign || function(t) { 24: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 20: }; 21: })(); 22: var __assign = (this && this.__assign) || function () { ^ 23: __assign = Object.assign || function(t) { 24: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __assign = (this && this.__assign) || function () { ^ 2: __assign = Object.assign || function(t) { 3: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __assign = (this && this.__assign) || function () { ^ 2: __assign = Object.assign || function(t) { 3: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 2: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 3: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 2: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 3: for (var r = Array(s), k = 0, i = 0; i < il; i++) ✔ service worker (27ms)

Listening on http://localhost:3000

When accessing localhost in a browser after adding the following to _layout.svelte

<script context="module">
  import { waitLocale } from 'svelte-i18n';

  export async function preload() {
    // awaits for the loading of the 'en-US' and 'en' dictionaries
    return waitLocale();
  }
</script>

I get the following error within the console and the page no longer loads.

console log

TypeError: Cannot read property ‘split’ of null at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108) at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934) at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039) at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7256) at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\user-35f39f10.js:348:20) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2410:29) at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2298:3) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2462:5) at processTicksAndRejections (internal/process/task_queues.js:93:5) TypeError: Cannot read property ‘split’ of null at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108) at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934) at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039) at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7256) at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\user-35f39f10.js:348:20) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2410:29) at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2298:3) at Array.find_route (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2614:3) at nth_handler (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2731:14) at C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2731:31

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JohnRSimcommented, Jan 8, 2020

if I run

npm run dev

works fine but when I run

npm run export

I now get this error:

> Built in 15.7s
> Crawling http://localhost:3000/
TypeError: Cannot read property 'split' of null
    at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108)
    at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934)
    at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039)
    at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7275)
    at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\app-46c76819.js:372:20)
    at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2420:29)
    at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2308:3)
    at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2472:5)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
      32 B   (500) index.html
TypeError: Cannot read property 'split' of null
    at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108)
    at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934)
    at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039)
    at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7275)
    at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\app-46c76819.js:372:20)
    at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2420:29)
    at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2308:3)
    at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2472:5)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
      32 B   (500) service-worker-index.html

> Finished in 16.7s. Type npx serve __sapper__/export to run the app.
1reaction
JohnRSimcommented, Jan 14, 2020

Thanks @kaisermann all working now! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

'this' keyword is equivalent to 'undefined' · Issue #1518 - GitHub
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
Read more >
rollup.JS and "'this' keyword is equivalent to 'undefined'
rollup.JS and "'this' keyword is equivalent to 'undefined' ; 'this' keyword is equivalent to 'undefined' ; ES module ; node_modules\@angular\forms ...
Read more >
undefined - JavaScript - MDN Web Docs - Mozilla
The global undefined property represents the primitive value undefined . It is one of JavaScript's primitive types.
Read more >
A brand new website interface for an even better experience!
'this' keyword is equivalent to 'undefined'
Read more >
null and undefined - JavaScript: The Definitive Guide ... - O'Reilly
undefined is a predefined global variable (not a language keyword like null ) that is initialized to the undefined value. In ECMAScript 3,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found