Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

convert value to string before calling replace() #8

Closed
wants to merge 2 commits into from

Conversation

LCHarold
Copy link

@LCHarold LCHarold commented Sep 5, 2018

Explicitly convert value to string to fix error "TypeError: __html.replace is not a function"

I don't know precisely what in my project is causing the error, but converting to string first fixes it. I'm using inline-css... maybe it's passing the value as null or undefined?

@coveralls
Copy link

coveralls commented Sep 5, 2018

Coverage Status

Coverage decreased (-42.6%) to 57.353% when pulling 67b4027 on LCHarold:master into 485726a on jonkemp:master.

@jonkemp
Copy link
Owner

jonkemp commented Sep 6, 2018

I don't think this is needed. Make sure you have the latest dependencies for inline-css. It should work then.

@LCHarold
Copy link
Author

LCHarold commented Sep 7, 2018

With these dependencies installed (from package-lock.json) I get the error:

    "inline-css": {
      "version": "2.4.0",
      "resolved": "https://registry.npmjs.org/inline-css/-/inline-css-2.4.0.tgz",
      "integrity": "sha1-3wyZkDuhy68G/PXJMZ/5Gw8a7L8=",
      "dev": true,
      "requires": {
        "bluebird": "^3.5.1",
        "cheerio": "^0.22.0",
        "css-rules": "^1.0.3",
        "extend": "^3.0.1",
        "extract-css": "^1.2.0",
        "flatten": "^1.0.2",
        "object.pick": "^1.3.0",
        "slick": "^1.12.2",
        "specificity": "^0.3.2"
      }
    },
...
    "extract-css": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/extract-css/-/extract-css-1.2.0.tgz",
      "integrity": "sha1-vlOQ9AnIWwy18buQKZx35RaIqN4=",
      "dev": true,
      "requires": {
        "batch": "^0.6.1",
        "href-content": "^1.0.2",
        "list-stylesheets": "^1.2.1",
        "style-data": "^1.3.0"
      },
      "dependencies": {
        "list-stylesheets": {
          "version": "1.2.1",
          "resolved": "https://registry.npmjs.org/list-stylesheets/-/list-stylesheets-1.2.1.tgz",
          "integrity": "sha1-eX82xaRU8xE2kZc970Lk8Mxm3+s=",
          "dev": true,
          "requires": {
            "cheerio": "^0.22.0",
            "extend": "^3.0.1",
            "object.pick": "^1.3.0"
          }
        }
      }
    },

Which generates the error:

TypeError: __html.replace is not a function
at C:\repo\myProject\node_modules\extract-css\node_modules\list-stylesheets\index.js:27:33

While explicitly declaring dependency on list-stylesheets from my fork results in these dependencies and no error:

    "inline-css": {
      "version": "2.4.0",
      "resolved": "https://registry.npmjs.org/inline-css/-/inline-css-2.4.0.tgz",
      "integrity": "sha1-3wyZkDuhy68G/PXJMZ/5Gw8a7L8=",
      "dev": true,
      "requires": {
        "bluebird": "^3.5.1",
        "cheerio": "^0.22.0",
        "css-rules": "^1.0.3",
        "extend": "^3.0.1",
        "extract-css": "^1.2.0",
        "flatten": "^1.0.2",
        "object.pick": "^1.3.0",
        "slick": "^1.12.2",
        "specificity": "^0.3.2"
      }
    },
...
    "extract-css": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/extract-css/-/extract-css-1.2.0.tgz",
      "integrity": "sha1-vlOQ9AnIWwy18buQKZx35RaIqN4=",
      "dev": true,
      "requires": {
        "batch": "^0.6.1",
        "href-content": "^1.0.2",
        "list-stylesheets": "^1.2.1",
        "style-data": "^1.3.0"
      }
    },
...
    "list-stylesheets": {
      "version": "github:LCHarold/list-stylesheets#641a03e5d0a186660e91d3755e1a0c389d6f766d",
      "from": "github:LCHarold/list-stylesheets#master",
      "dev": true,
      "requires": {
        "cheerio": "^0.22.0",
        "extend": "^3.0.1",
        "object.pick": "^1.3.0"
      }
    },

Finally, just to make a true apples-to-apples comparison, I changed the dependency from my fork to github:jonkemp/list-stylesheets#master, re-installed, and once again got the error.

@jonkemp
Copy link
Owner

jonkemp commented Sep 10, 2018

Can you create a bug report for this?

…unction"

to reproduce, do "npm run coverage" which will run and then invoke "postcoverage" which in turn calls ./setup/process-coverage-report.js, which is where the error happens
you can then demonstrate that converting _html to String first resolves the issue by adding my updated list-stylesheets code to the dependencies with "list-stylesheets": "github:LCHarold/list-stylesheets#master"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants