简体   繁体   English

无法解决安装的 Npm 模块

[英]Cant Resolve Installed Npm Module

I uninstalled the package @toast-ui/react-image-editor from the server side of my react app because I thought the dependency needed to be client side, so I go and install it client side, and reboot the app and it cannot be found.我从我的反应应用程序的服务器端卸载了 package @toast-ui/react-image-editor 因为我认为依赖项需要是客户端,所以我 go 并安装它在客户端,然后重新启动应用程序,它不能成立。

Heres my basic folder structure这是我的基本文件夹结构

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

I receive this error: "./src/components/images/Editor.js Module not found: Can't resolve '@toast-ui/react-image-editor' in 'C:..\client\src\components\images'"我收到此错误:“./src/components/images/Editor.js Module not found: Can't resolve '@toast-ui/react-image-editor' in 'C:..\client\src\components\图片'”

Following that I consulted之后我咨询了

How do I resolve "Cannot find module" error using Node.js? 如何使用 Node.js 解决“找不到模块”错误?

Can't resolve module (not found) in React.js 无法解析 React.js 中的模块(未找到)

Basically I have deleted and installed the individual package, deleted and installed the node_modules on the client and the server run npm cache verify, installed the package on the client only, installed the package on the client and the server, installed on the server only. Basically I have deleted and installed the individual package, deleted and installed the node_modules on the client and the server run npm cache verify, installed the package on the client only, installed the package on the client and the server, installed on the server only.

and nothing is working, which makes me think possibly its an import error with VS Code,并且没有任何工作,这让我认为它可能是 VS Code 的导入错误,

is there a way to see how npm is trying to import a specific package or any general thing I haven't done for react failing to import a package that's clearly there.有没有办法查看 npm 是如何尝试导入特定的 package 或我没有做的任何一般性的事情,因为反应未能清楚地导入 package。

I got the same error.我得到了同样的错误。 I think there is a problem with the recent version 3.14.3.我认为最近的3.14.3版本有问题。 I went back to 3.14.2 and it worked fine.我回到 3.14.2,它运行良好。 Here is my sample App.js to get you started, based on the npm page.这是我的示例 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM