无法在 Skyscanner 上运行背包

问题描述 投票:0回答:2

出现以下错误,React 应用程序最初未编译,我在 NodeJS 上遇到了旧的 SSL 安全错误,感谢 stackoverflow,我能够修复该问题,但现在我面临着这个问题。

Failed to compile.

./node_modules/@skyscanner/backpack-web/bpk-component-button/src/BpkButton.js
SyntaxError: C:\Users\prantik\Desktop\SkyScanner Internship\my-app\node_modules\@skyscanner\backpack-web\bpk-component-button\src\BpkButton.js: Missing semicolon. (45:4)

Failed to compile.

./node_modules/@skyscanner/backpack-web/bpk-component-button/src/BpkButton.js
SyntaxError: C:\Users\prantik\Desktop\SkyScanner Internship\my-app\node_modules\@skyscanner\backpack-web\bpk-component-button\src\BpkButton.js: Unexpected token, expected "," (40:7)

  38 |
  39 | import {
> 40 |   type Props as CommonProps,
     |        ^
  41 |   propTypes,
  42 |   defaultProps,
  43 | } from '@skyscanner/backpack-web/bpk-component-button/src/common-types';   
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)

BpkButton.js
有以下代码

import React from 'react';
import { BpkCode } from '@skyscanner/backpack-web/bpk-component-code';
import BpkButton from '@skyscanner/backpack-web/bpk-component-button';
import BpkText from '@skyscanner/backpack-web/bpk-component-text';

import { cssModules } from '@skyscanner/backpack-web/bpk-react-utils';

import STYLES from './App.scss';

const getClassName = cssModules(STYLES);

const App = () => (
  <div className={getClassName('App')}>
    <header className={getClassName('App__header')}>
      <div className={getClassName('App__header-inner')}>
        <BpkText tagName="h1" textStyle="xxl" className={getClassName('App__heading')}>Flight Schedule</BpkText>
      </div>
    </header>
    <main className={getClassName('App__main')}>
      <BpkText tagName="p" className={getClassName('App__text')}>
        To get started, edit <BpkCode>src/App.jsx</BpkCode> and save to reload.
      </BpkText>
      <BpkButton onClick={() => alert('It works!')}>Click me</BpkButton>
    </main>
  </div>
);

export default App;

我尝试安装打字稿,但不知道如何解决这个问题。

reactjs typescript skyscanner
2个回答
0
投票

将其添加到您的 package.json

"backpack-react-scripts": {
    "babelIncludePrefixes": [
      "@skyscanner/backpack-web"
    ]
  }

0
投票

你能修好它吗?我也遇到同样的问题

© www.soinside.com 2019 - 2024. All rights reserved.