Reputation: 61
After upgrading rehype-katex
from 5.0.0
to 6.0.1
, when I run yarn start
, I got:
./node_modules/hast-util-to-text/index.js 363:65
Module parse failed: Identifier directly after number (363:65)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| // break is the zero-width space character (U+200B), then the break is
| // removed, leaving behind the zero-width space.
> if (lines[index].charCodeAt(lines[index].length - 1) === 0x20_0b
| /* ZWSP */
| || index < lines.length - 1 && lines[index + 1].charCodeAt(0) === 0x20_0b
But it works fine in codesandbox, and yarn build
is also OK. How do I fix this?
My package.json:
{
"name": "blog",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"gh-pages": "^3.2.3",
"pubsub-js": "^1.9.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-markdown": "^7.0.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-syntax-highlighter": "^15.4.4",
"rehype-katex": "^6.0.1", // Upgrade
"rehype-raw": "^6.0.0",
"remark-gfm": "^2.0.0",
"remark-math": "^5.0.0",
"web-vitals": "^2.1.0"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://xxx.github.io"
}
Upvotes: 5
Views: 4312
Reputation: 11
I am using this way and got error const MAX_UID = 1_000_000
when i turn this into const MAX_UID = 1000000
its working perfect
Error coming due to the old version of the node i am using v14
for my project when using new version error not coming
Upvotes: 1
Reputation: 4507
Had the same problem after updates, underscore separator in numbers raised this same error ("Module parse failed: Identifier directly after number").
It was due to Babel, the issue was solved by adding the @babel/plugin-proposal-numeric-separator
plugin.
Upvotes: 3
Reputation: 689
I had the same error, and it took me longer than I'm willing to admit to find its cause. For me, it was underscores within number literals.
num = 2_000; // bad bad not good
num = 2000; // no probs
Upvotes: 4
Reputation: 21
I had the exactly same problem and have fixed the issue by following this SO POST: https://stackoverflow.com/a/67574280/16766691
Just go to package.json under your project root folder,
replace
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
with
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
]
And then recompile your project.
Upvotes: 2
Reputation: 6629
If I had to take a guess, I’d say REMOVE node_modules & package-lock.json or yarn.lock THEN yarn AGAIN.
Sometimes upgrade module will cause unknown error.
Upvotes: 1