小编DGB*_*DGB的帖子

启动时create-react-app“无法编译”

使用npm开始打开create-react-app 时出现以下错误。我是React的新手,过去几天我在做命令行以创建新应用程序时没有遇到任何问题。

我已尝试npx启动,npm启动并npm重新安装更新版本。

Failed to compile
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
BrowserslistError: Unknown browser query `android all`. Maybe you are using old Browserslist or made typo in query.
    at Array.reduce (<anonymous>)
    at Array.some (<anonymous>)
    at Array.filter (<anonymous>)
Run Code Online (Sandbox Code Playgroud)

npm reactjs create-react-app

20
推荐指数
1
解决办法
4813
查看次数

在 Nextjs 中使用 getServerSideProps 进行动态路由

我正在尝试学习nextjs。正在努力使用getServerSideProps.

使用免费的 api,我在 DOM 上显示了一个国家列表。我想动态链接到一个国家/地区,并为该特定国家/地区获取和显示数据。

到目前为止,这是我的代码

const Country = props => (
  <Layout>
    <h1>{props.country.name}</h1>
    <span>{props.country.capital}</span>
  </Layout>
);
export async function getServerSideProps(context) {
  const { id } = context.query;
  const res = await fetch(`https://restcountries.eu/rest/v2/name/${id}`);
  const country = await res.json();

  console.log(`Fetched place: ${country.name}`);
  return { props: { country } };
}
export default Country;

Run Code Online (Sandbox Code Playgroud)
  <div className='container'>
    <Head>
      <title>Countries List</title>
      <link rel='icon' href='/favicon.ico' />
    </Head>
    <Layout>
      <main>
        <h1>
          Countries{' '}
          <span role='img' aria-label='world emoji'>
            
          </span>
        </h1>
        <ul>
          {countries.map(country => (
            <li …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

11
推荐指数
1
解决办法
1万
查看次数

Gatsby项目出现奇怪的错误,无法构建

我npm install --save gatsby-transformer-sharp gatsby-plugin-sharp,然后这样做后,我无法运行我的项目,并且遇到了这些奇怪的错误:

(sharp:7804): GLib-GObject-WARNING **: 14:10:08.042: cannot register existing type 'VipsObject'

(sharp:7804): GLib-CRITICAL **: 14:10:08.043: g_once_init_leave: assertion 'result != 0' failed

(sharp:7804): GLib-GObject-CRITICAL **: 14:10:08.043: g_type_register_static: assertion 'parent_type > 0' failed

(sharp:7804): GLib-CRITICAL **: 14:10:08.043: g_once_init_leave: assertion 'result != 0' failed
Run Code Online (Sandbox Code Playgroud)

gatsby

9
推荐指数
1
解决办法
390
查看次数

标签 统计

reactjs ×2

create-react-app ×1

gatsby ×1

next.js ×1

npm ×1