微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法解决已安装的 Npm 模块

如何解决无法解决已安装的 Npm 模块

我从我的 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 未能导入明显存在的包。

解决方法

我遇到了同样的错误。 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;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。