TypeError: Cannot read property 'tokenizePlaceholders' of undefined
See original GitHub issueHello,
When I use version 1.14.0 in node.js, I get an undefined error (which is not present when I use 1.13.0) I would guess it is a problem with the php component. Can someone reproduce it?
example:
const Prism = require('prismjs')
require('prismjs/components/prism-php')
require('prismjs/components/prism-python')
console.log('Available languages:')
console.log(JSON.stringify(Object.keys(Prism.languages)))
let code = 'just a string'
let lang = 'php'
lang = 'python'
console.log(`${lang}: "${Prism.highlight(code, Prism.languages[lang])}"`)
When I use prismjs@1.14.0 I receive this output:
Available languages:
["extend","insertBefore","DFS","markup","xml","html","mathml","svg","css","clike","javascript","js","php","python"]
D:\test\node_modules\prismjs\components\prism-php.js:121
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
^
TypeError: Cannot read property 'tokenizePlaceholders' of undefined
at D:\test\node_modules\prismjs\components\prism-php.js:121:40
at Object.run (D:\test\node_modules\prismjs\prism.js:456:5)
at Object.highlight (D:\test\node_modules\prismjs\prism.js:287:11)
at Object.<anonymous> (D:\test\problem.js:13:32)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
If I remove the line require('prismjs/components/prism-php')
, I get the desired output:
Available languages:
["extend","insertBefore","DFS","markup","xml","html","mathml","svg","css","clike","javascript","js","python"]
python: "just a string"
I also get the same output if I use prismjs@1.13.0 instead
Maybe it was introduced with #1367 ?
Regards, marc
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read properties of undefined ...
The above config causes the file gets loaded as a string that points to its URL, but the code assumes a JS object...
Read more >Fix 'cannot read properties of undefined (reading map)' in JS
Learn what is the cause, and how you can fix 'Uncaught TypeError: Cannot read properties of undefined (reading 'map')' errors in JavaScript.
Read more >Use error report in vue3? | v-md-editor - GitHub Pages
Vuepress theme quotes php language pack error? Error:Cannot read property 'tokenizePlaceholders' of undefined. Solution: // Before introducing the php language ...
Read more >解决Prismjs 'tokenizePlaceholders' of undefined 问题 - 码道人
... 化到token,个人博客打算切换markdown 高亮方案为prismjs,且换的时候出现了以下错误:. TypeError: Cannot read property 'tokenizePlaceholders' of undefined ...
Read more >[Prism.js] tokenizePlaceholders of undefinedエラーの対処方法
jsを 1.13.0 から 1.14.0 へバージョンアップした際に下記のようなエラーが発生した。 Uncaught (in promise) TypeError: Cannot read property ' ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone who comes here and is not using node or Webpack, you have to include
prismjs/components/prism-markup-templating.js
beforeprismjs/components/prism-php.js
to fix the error in this issue.