Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

打包报错是怎么回事呢? #34

Open
fengchuanlin opened this issue Oct 10, 2023 · 1 comment
Open

打包报错是怎么回事呢? #34

fengchuanlin opened this issue Oct 10, 2023 · 1 comment

Comments

@fengchuanlin
Copy link

作者您好,我遇到一个问题,就是我打包时会报ts的错,这个是怎么回事呢?
报错具体代码:
npm run build

blog@0.1.0 build
tsc && vite build

src/sections/About/index.tsx:5:19 - error TS7016: Could not find a declaration file for module 'react-reveal/Pulse'. 'C:/Users/123/Downloads/pengBlog-master/pengBlog-master/index/node_modules/react-reveal/Pulse.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-reveal if it exists or add a new declaration (.d.ts) file containing declare module 'react-reveal/Pulse';

5 import Pulse from 'react-reveal/Pulse';
~~~~~~~~~~~~~~~~~~~~

src/sections/About/index.tsx:6:23 - error TS7016: Could not find a declaration file for module 'react-reveal/HeadShake'. 'C:/Users/123/Downloads/pengBlog-master/pengBlog-master/index/node_modules/react-reveal/HeadShake.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-reveal if it exists or add a new declaration (.d.ts) file containing declare module 'react-reveal/HeadShake';

6 import HeadShake from 'react-reveal/HeadShake';
~~~~~~~~~~~~~~~~~~~~~~~~

src/sections/Home/index.tsx:8:22 - error TS2307: Cannot find module './pagemore.json' or its corresponding type declarations.

8 import pageMore from "./pagemore.json"
~~~~~~~~~~~~~~~~~

src/sections/Project/index.tsx:43:60 - error TS2322: Type '{ className: string; ref: MutableRefObject<HTMLDivElement | null>; alt: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'.
Property 'alt' does not exist on type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'.

43


~~~

Found 4 errors in 3 files.

Errors Files
2 src/sections/About/index.tsx:5
1 src/sections/Home/index.tsx:8
1 src/sections/Project/index.tsx:43

@fengchuanlin
Copy link
Author

作者您好,我遇到一个问题,就是我备份时会报错,这是怎么回事呢? 报错具体代码: npm run build

blog@0.1.0 构建
tsc && vite 构建

src/sections/About/index.tsx:5:19 - 错误 TS7016:找不到模块“react-reveal/Pulse”的声明文件。'C:/Users/123/Downloads/pengBlog-master/pengBlog-master/index/node_modules/react-reveal/Pulse.js' 隐式具有“any”类型。 尝试npm i --save-dev @types/react-reveal它是否存在或添加一个新的声明(.d.ts)文件,其中包含declare module 'react-reveal/Pulse';

5 从'react-reveal/Pulse'导入Pulse; ~~~~~~~~~~~~~~~~~~~~~

src/sections/About/index.tsx:6:23 - 错误 TS7016:找不到模块“react-reveal/HeadShake”的声明文件。'C:/Users/123/Downloads/pengBlog-master/pengBlog-master/index/node_modules/react-reveal/HeadShake.js' 隐式具有“any”类型。 尝试npm i --save-dev @types/react-reveal它是否存在或添加一个新的声明(.d.ts)文件,其中包含declare module 'react-reveal/HeadShake';

6 从 'react-reveal/HeadShake' 导入 HeadShake; ~~~~~~~~~~~~~~~~~~~~~~~~

src/sections/Home/index.tsx:8:22 - 错误 TS2307:找不到模块“./pagemore.json”或其相应的类型声明。

8 从“./pagemore.json”导入pageMore ~~~~~~~~~~~~~~~~~~

src/sections/Project/index.tsx:43:60 - 错误 TS2322:类型 '{ className: string; 参考:MutableRefObject<HTMLDivElement | 空>; 替代:字符串;}' 不可分配给类型“DetailedHTMLProps<HTMLAttributes, HTMLDivElement>”。 类型“DetailedHTMLProps<HTMLAttributes, HTMLDivElement>”上不存在属性“alt”。

43

在 3 个文件中发现 4 个错误。

错误文件 2 src/sections/About/index.tsx:5 1 src/sections/Home/index.tsx:8 1 src/sections/Project/index.tsx:43

该问题解决了,是我太粗心啦。 需要在vite-env.d.ts 文件下添加类型。 添加上就完成了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant