无法解决已安装的 Npm 模块

时间:2021-05-01 18:13:26

标签: node.js reactjs npm toast-ui-image-editor

我从我的 react 应用程序的服务器端卸载了包 @toast-ui/react-image-editor 因为我认为依赖需要在客户端,所以我去安装它客户端,然后重新启动应用程序和找不到。

这是我的基本文件夹结构

 -myapp
    -server.js
    -package.json
    -node_modules
    -package-lock.json
    -client
       -package.json
       -node_modules
       -package-lock.json
       -src

我收到此错误:“./src/components/images/Editor.js 找不到模块:无法解析 'C:..\client\src\components\images' 中的 '@toast-ui/react-image-editor'"

以下是我咨询的

How do I resolve "Cannot find module" error using Node.js?

Can't resolve module (not found) in React.js

基本上我已经删除并安装了单个包,删除并安装了客户端和服务器上的node_modules运行npm缓存验证,仅安装了客户端上的包,安装了客户端和服务器上的包,安装在仅限服务器。

没有任何效果,这让我觉得可能是 VS Code 的导入错误,

有没有办法查看 npm 如何尝试导入特定包或任何我没有做过的一般性操作,因为 react 未能导入明显存在的包。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的错误。 I think there is a problem with the recent version 3.14.3. 我回到 3.14.2 并且运行良好。这是我的示例 App.js,可帮助您入门,基于 npm 页面。

import 'tui-image-editor/dist/tui-image-editor.css';
import ImageEditor from '@toast-ui/react-image-editor';

function App() {

  const myTheme = {
    // Theme object to extends default dark theme.
  };
  
  const MyComponent = () => (
    <ImageEditor
      includeUI={{

        theme: myTheme,
        menu: ['shape', 'filter'],
        initMenu: 'filter',
        uiSize: {
          width: '1000px',
          height: '700px',
        },
        menuBarPosition: 'bottom',
      }}
      cssMaxHeight={500}
      cssMaxWidth={700}
      selectionStyle={{
        cornerSize: 20,
        rotatingPointOffset: 70,
      }}
      usageStatistics={true}
    />
  );

  return (
    <div className="App">
      <header className="App-header">
      <div><MyComponent /></div>
      </header>
    </div>
  );
}

export default App;
相关问题