Can't import to React
See original GitHub issueHi, I am not able to import shiki into a react app. I am getting Uncaught TypeError: fs.readFileSync is not a function
error.
Here’s my code for reference.
import './App.css'
import { useEffect, useState } from 'react'
import shiki from 'shiki'
shiki.getHighlighter({
theme: 'nord'
}).then(highlighter => {
console.log(highlighter.codeToHtml(`console.log('shiki');`, 'js'))
})
...
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Cannot import react js component - Stack Overflow
I post simpler version which I know does work: ./index.js : import React from 'react'; import ReactDOM from 'react-dom'; import Application ...
Read more >Can't use import React from 'react' · Issue #543 - GitHub
I'm newbie in react. I'm using this gem with a rails app, using es6 and jsx. In assets/javascripts/components/message.es6.jsx class Message ...
Read more >Importing Components in React From Other Files - Upmostly
There is a key import limitation in React which we haven't discussed thus far: you cannot import from files outside the src directory....
Read more >Module not found: Can't resolve 'X' error in React | bobbyhadz
The error "Module not found: Can't resolve" occurs for multiple reasons in React: Importing a local file from an incorrect relative path.
Read more >Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
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 FreeTop 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
Top GitHub Comments
@i9or Thanks for the detailed description and repro.
For 2. and 3. should be fixed in the recent commits.
For 1. You can use your current solution or via third-party CDNs like unpkg or jsdelivr. If you’d like to bundle those file, you can do them this way:
I can, and I have - this is shipped in 0.9.2 👍🏻