创建 React App 在启动服务器时抛出错误
Create React App throws error while starting server
每当我 运行 npm start
.
时都会出现此错误
我试过了npm install
。我在控制台中没有错误。
此外,我没有在我的任何文件中使用 JSON.parse
。
完整错误:
Starting the development server...
C:\Users\user\Documents\GitHub\repo\client\node_modules\react-scripts\scripts\start.js:19
throw err;
^
SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)
at Object.getBuildInfo (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:107937:21)
at readBuilderProgram (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:120294:28)
at Object.createWatchProgram (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:120448:26)
at Object.<anonymous> (C:\Users\user\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:304:59)
at Generator.next (<anonymous>)
at C:\Users\Vito\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\Vito\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:4:12)
at Object.getIssues (C:\Users\user\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:227:28)
试试这个步骤
删除node_modules
再次安装节点包npm i
每当我 运行 npm start
.
我试过了npm install
。我在控制台中没有错误。
此外,我没有在我的任何文件中使用 JSON.parse
。
完整错误:
Starting the development server...
C:\Users\user\Documents\GitHub\repo\client\node_modules\react-scripts\scripts\start.js:19
throw err;
^
SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)
at Object.getBuildInfo (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:107937:21)
at readBuilderProgram (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:120294:28)
at Object.createWatchProgram (C:\Users\user\Documents\GitHub\repo\client\node_modules\typescript\lib\typescript.js:120448:26)
at Object.<anonymous> (C:\Users\user\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:304:59)
at Generator.next (<anonymous>)
at C:\Users\Vito\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\Vito\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:4:12)
at Object.getIssues (C:\Users\user\Documents\GitHub\repo\client\node_modules\fork-ts-checker-webpack-plugin\lib\typescript-reporter\reporter\TypeScriptReporter.js:227:28)
试试这个步骤
删除
node_modules
再次安装节点包
npm i