小编Rob*_*gar的帖子

使用 npm 安装失败,json 响应无效

我之前已经安装了 npm,但由于某种原因我不得不卸载它。现在,我尝试再次安装 npm 以使用此命令创建 React 应用程序。

npx create-react-app ip_tracker

安装到一半的时候发现这个错误

npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/@babel%2fpreset-react reason: Unexpected end of JSON input

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ngebelcilik/.npm/_logs/2020-11-27T14_34_28_241Z-debug.log
Run Code Online (Sandbox Code Playgroud)

这是日志

0 verbose cli [
0 verbose cli   '/usr/bin/node',
0 verbose cli   '/usr/share/nodejs/npm/bin/npm-cli.js',
0 verbose cli   'exec',
0 verbose cli   '--',
0 verbose cli   'create-react-app',
0 verbose cli   'ip_tracker'
0 verbose cli ] …
Run Code Online (Sandbox Code Playgroud)

node.js npm package.json

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

在纱线中安装所有未满足的依赖项

我的反应应用程序中有错误,它说:

    Line 0:  Parsing error: Cannot find module 'eslint-scope' from '/home/path/.cache/yarn/v6/npm-eslint-7.11.0-aaf2d23a0b5f1d652a08edacea0c19f7fadc0b3b-integrity/node_modules/eslint/lib/api.js'
Run Code Online (Sandbox Code Playgroud)

然后我使用以下命令将 eslint-scope 添加到我的依赖项中:

    yarn add eslint-scope
Run Code Online (Sandbox Code Playgroud)

但是我发现了很多未满足的对等依赖项:

    warning " > @testing-library/user-event@12.1.10" has unmet peer dependency "@testing-library/dom@>=7.21.4".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/eslint-plugin@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/parser@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "babel-eslint@^10.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-flowtype@^5.2.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-import@^2.22.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency …
Run Code Online (Sandbox Code Playgroud)

javascript dependencies node.js reactjs yarnpkg

6
推荐指数
1
解决办法
474
查看次数

如何禁用 svelte 中未使用的样式警告

我有一个用于全局样式的 CSS 规则,该样式有效,但我的终端一直向我显示此警告,如何禁用它?

\n
src/components/Navbar.svelte changed. rebuilding...\n\xe2\x80\xa2 server\nsrc/routes/index.svelte\nModule Warning (from ./node_modules/svelte-loader-hot/index.js):\nUnused CSS selector "*" (22:2)\n20: \n21: <style global>\n22:   * {\n      ^\n23:     font-family: 'Poppins';\n24:   }\n\xe2\x80\xa2 client\nsrc/routes/index.svelte\nModule Warning (from ./node_modules/svelte-loader-hot/index.js):\nUnused CSS selector "*" (22:2)\n20: \n21: <style global>\n22:   * {\n      ^\n23:     font-family: 'Poppins';\n24:   }\n\xe2\x9c\x94 service worker (73ms)\n\n
Run Code Online (Sandbox Code Playgroud)\n

svelte sapper

6
推荐指数
1
解决办法
2175
查看次数

在下一个js中定位图像

我想将我的图像放在页面的最右侧,我尝试使用 和 进行position: absolute修改right: 0。我还尝试将父位置设置为相对位置,将图像位置设置为绝对位置,但为什么它不起作用?

这是我的 jsx 文件

        <div className={styles.images}>
          <Image
            src="/cloud.svg"
            alt="Picture of the author"
            layout="fill"
            className={styles.cloud}
          />
          <Image
            src="/kuil.svg"
            alt="Picture of the author"
            height={200}
            width={600}
            layout="intrinsic"
            className={styles.building}
          />
        </div>
Run Code Online (Sandbox Code Playgroud)

也在我的 css 文件中。

.images {
    position: relative;
    margin: 90px auto 0 auto;
}

.building {
    position: absolute;
    top: 0;
    right: 0 !important;
    bottom: 0 !important;
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

css reactjs next.js

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

如何使用地图功能做出3列网格反应

我有一些卡片,我想让它看起来像这样

[] [] []
[] [] []
[] [] []
...
...

Run Code Online (Sandbox Code Playgroud)

我在使用地图功能渲染项目时遇到问题。我已经尝试过这个,但它不起作用。对于每个索引,如果索引可被 3 整除,我想创建新行。我怎样才能做到这一点?

                {products.map((val, index) => (
                    { index%3 == 0 ? <div className="row mx-auto"> : null}
                    <Card>
                      {val.description}
                    </Card>
                    { index%3 == 0 ? </div> : null}
                ))}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激。

javascript arrays reactjs bootstrap-4

5
推荐指数
1
解决办法
6748
查看次数

Rust中的后缀注释是什么?

我读了这个文档并偶然发现了这一行。

let an_integer = 5i32; // Suffix annotation

这是什么意思?我假设它的值是 5,整数类型是 i32。那是对的吗?

rust

3
推荐指数
1
解决办法
851
查看次数

使用单元结构的真实示例是什么?

我阅读了这些关于结构的文档,但我不了解单元结构。它说:

单元结构最常用作标记。它们的大小为零字节,但与空枚举不同,它们可以被实例化,使它们与单元类型同构()。当您需要在某物上实现特征但不需要在其中存储任何数据时,单元结构很有用。

他们只以这段代码为例:

struct Unit;
Run Code Online (Sandbox Code Playgroud)

使用单元结构的真实示例是什么?

struct rust

3
推荐指数
1
解决办法
146
查看次数

类型错误模块“react-leaflet”没有导出成员“useEventHandlers”

我有 nextjs 应用程序+打字稿+反应传单

当我启动我的开发服务器时,npm run dev一切都很好,没有错误,但是当我开始构建时,npm run build我有一个错误,它说。

Type error: Module '"react-leaflet"' has no exported member 'useEventHandlers'.

  1 | import { useMemo, useCallback, useState } from 'react'
> 2 | import { useMap, useMapEvent, useEventHandlers, MapContainer } from 'react-leaflet'
    |                               ^
  3 |
  4 | // Classes used by Leaflet to position controls
  5 | const POSITION_CLASSES = {
info  - Checking validity of types .
Run Code Online (Sandbox Code Playgroud)

这是我的package.json文件。

{
  "name": "spot-nearby",
  "version": "0.1.0",
  "private": true, …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-leaflet next.js

3
推荐指数
1
解决办法
1631
查看次数