pengBlog icon indicating copy to clipboard operation
pengBlog copied to clipboard

打包报错是怎么回事呢?

Open fengchuanlin opened this issue 2 years ago • 1 comments

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

[email protected] 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>, HTMLDivElement>'. Property 'alt' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.

43 <div className={styles.workspaceimg} ref={toysRef} alt="rocket"> ~~~

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 avatar Oct 10 '23 04:10 fengchuanlin

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

[email protected] 构建 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 文件下添加类型。 添加上就完成了

fengchuanlin avatar Oct 11 '23 05:10 fengchuanlin