【问题标题】:Cant Resolve Installed Npm Module无法解决已安装的 Npm 模块
【发布时间】:2021-05-01 18:13:26
【问题描述】:

我从我的 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 无法导入明显存在的包而做的任何一般事情。

【问题讨论】:

  • 有时 vs code 不能正确获取新安装的包。尝试重启 ts 服务器(ctrl + p,然后在命令中搜索“ts server”)
  • toast ui 的优秀人员有一些解释为什么 3.12 加载良好但 3.14 很挑剔

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


【解决方案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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-03
    • 2014-11-19
    • 2015-08-23
    • 2015-11-15
    • 1970-01-01
    • 2018-09-23
    • 2021-12-15
    • 1970-01-01
    相关资源
    最近更新 更多