Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 找不到模块的声明文件'/path/to/module name.js';隐式具有';任何';类型_Javascript_Reactjs_Gatsby - Fatal编程技术网

Javascript 找不到模块的声明文件'/path/to/module name.js';隐式具有';任何';类型

Javascript 找不到模块的声明文件'/path/to/module name.js';隐式具有';任何';类型,javascript,reactjs,gatsby,Javascript,Reactjs,Gatsby,我正在学习Gatsby.js教程,在教程2中,您必须导入一些字体。当我尝试导入主题lawton时,我在从“排版主题lawton”导入lawton主题下看到此错误 我首先安装了npm——保存排版主题lawton Could not find a declaration file for module 'typography-theme-lawton'. '/Users/react/tutorial-part-two/node_modules/typography-theme-lawton/di

我正在学习Gatsby.js教程,在教程2中,您必须导入一些字体。当我尝试导入<代码>主题lawton时,我在<代码>从“排版主题lawton”导入lawton主题下看到此错误

我首先安装了npm——保存排版主题lawton

  Could not find a declaration file for module 'typography-theme-lawton'. '/Users/react/tutorial-part-two/node_modules/typography-theme-lawton/dist/index.js' implicitly has an 'any' type.
  Try `npm install @types/typography-theme-lawton` if it exists or add a new declaration (.d.ts) file containing `declare module 'typography-theme-lawton';`
这是我的typography.js文件:

import Typography from "typography";
//import bootstrapTheme from " typography-theme-bootstrap";
import lawtonTheme from "typography-theme-lawton";

const typography = new Typography(lawtonTheme);

//const typography = new Typography({ baseFontSize: "18px" });
//const typography = new Typography(bootstrapTheme);

export default typography;
这是我的gatsby-config.js文件:

  module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography.js`
      }
    }
  ]
};
同样在盖茨比配置文件中,单词module是下划线,此注释显示:
[ts]文件是一个公共JS模块;它可以转换为ES6模块。[80001]


我也试过
npm安装@types/排版主题lawton
,但它给了我错误

基于您的问题,我猜您正在使用typescript,项目找不到ts模块。 您需要安装ts文件。请尝试以下操作:

npm install —-save @types/.....
或者,您可以在项目中的某个位置添加一个d.ts文件,并将上述内容添加到该文件中

declare module typography-theme-lawton
[ts]文件是一个CommonJS模块;它可以转换为ES6模块。[80001] 我假设您使用的是VSCode。请在设置中添加以下内容以启用它:

"javascript.suggestionActions.enabled": false
附言:这只是一个建议,所以你可以忽略这个