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.

Cannot read property 'rest' of undefined when using bash language

See original GitHub issue

Hello,

I was trying to use this great projet but i keep getting this error :

[2017-04-20 17:46:49.682] [ERROR] prizmLogs - TypeError: Cannot read property 'rest' of undefined
    at Object.tokenize (C:\Sources\TCN\prizmLogs\node_modules\prismjs\prism.js:265:21)
    at Object.highlight (C:\Sources\TCN\prizmLogs\node_modules\prismjs\prism.js:256:18)
    at C:\Sources\TCN\prizmLogs\routes\logs.js:36:22
    at Layer.handle [as handle_request] (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\layer.js:95:5)
    at C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Sources\TCN\prizmLogs\node_modules\express\lib\router\index.js:275:10)

I used your basic exemple :

   const prism = require('prismjs
   let body = 'test';
    try{
        body = prism.highlight(body, prism.languages.bash);

    }catch(err){
        logger.error(err);
        body = err.message;
    }

Nothing too fancy as you can see. Node version is 7.7.3 and npm version is 4.1.2.

Did i miss something ? like the fact that it’s not compatible with node 7.7.3 or whatever ?

Theo

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
mAAdhaTTahcommented, Apr 20, 2017

prism.languages.bash is probably undefined. When you require prismjs in node, you need to import the components: require(‘prismjs/components/bash’) or whatever the exact path is.

0reactions
mAAdhaTTahcommented, Jun 1, 2018

This: require('prismjs/components/bash') -> require('prismjs/components/prism-bash'). I didn’t type out the whole path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

path - VS code error: Cannot read properties of undefined ...
The "Cannot read properties of undefined" error occurs with the JavaScript of VC Code when you try to access a property or a...
Read more >
cannot read properties of undefined (reading 'listen') - You.com
I'm trying to get messages from a WebSocket to make assertions using Cypress. I used the example from the website link to do...
Read more >
Loop the loop: TypeError: Cannot read property 'name' of ...
Can anybody please tell me what is wrong with this code: // Our Person constructor ... Loop the loop: TypeError: Cannot read property...
Read more >
Bash Reference Manual - GNU.org
Your users will use the LANG or LC_MESSAGES shell variables to select the desired language. You set the TEXTDOMAIN variable to the script's ......
Read more >
Language Server Extension Guide - Visual Studio Code
First, Language Servers are usually implemented in their native programming languages, and that presents a challenge in integrating them with VS Code, which...
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