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.

Uncaught TypeError: ns.charCodeAt is not a function

See original GitHub issue

environment: “next”: “latest”, “styled-components”: “^2.1.1”,

below is my demo code

// index.js
import React from 'react';
import styled from 'styled-components';

const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: #ddd;
  `;
export default () => (
  <div>
    <Title>it is just an demo</Title>
  </div>
  );
   // _document.js
import Document, { Head, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components';
import flush from 'styled-jsx/server';

export default class MyDocument extends Document {
  static getInitialProps({ renderPage }) {
    const { html, head, errorHtml, chunks } = renderPage();
    const styles = flush();
    return { html, head, errorHtml, chunks, styles };
  }

  render() {
    const sheet = new ServerStyleSheet();
    const main = sheet.collectStyles(<Main />);
    const styleTags = sheet.getStyleElement();
    return (
      <html lang="zh">
        <Head>
          <style>{'body { margin: 0 } /* custom! */'}</style>
          {/* inject:js */}
          <script src="../static/demo.js" />
          {/* endinject */}
          {styleTags}
        </Head>
        <body className="custom_class">
          <div>root</div>
          <div className="root">
            {main}
          </div>
          <NextScript />
        </body>
      </html>
    );
  }
}

browser throw TypeError

image

but the Title component is work still

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kittencommented, Nov 15, 2017

I’ll close this due to its age and inactivity

Thanks @protoEvangelion for resurfacing it 😄

1reaction
ghostcommented, Jul 26, 2017

i try removing node_modules many times

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: str.charCodeAt is not a function - Stack Overflow
I updated to node version 6 today and that might've broke something. I tried to get back to node 5.10 but the issue...
Read more >
JavaScript: Uncaught TypeError: n is not a function
This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the...
Read more >
Charcodeat 不是一个函数javascript, 类型错误 - 免费编程教程
Uncaught TypeError: ns.charCodeAt is not a function · Issue #1033 ,当网站尝试加载检查器时显示以下错误: Uncaught TypeError: this._input.
Read more >
Node.js v19.3.0 Documentation
If the function has not been called exactly exact times when tracker.verify() is called, then tracker.verify() will throw an error. import assert from...
Read more >
t.charcodeat is not a function - You.com | The AI Search ...
TypeError : str.charCodeAt is not a function - Stack Overflow ... This could be an issue with some module not being entirely compatible...
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