(4)taro每日n坑---Module not found:

2020-08-24  本文已影响0人  Rose_yang

1、 场景: 引用自定义的组件的时候报错,但是引用路径没问题

image.png

2、错误产生原因: components文件夹中没有添加index.js文件

image.png

3、解决方案:src/components/index.js 文件内容如下

import BrandInfo from './BrandInfo/BrandInfo'

export {
  BrandInfo
}

4、结果: components文件夹中添加index.js文件后,编译成功

下面是报错信息

@JRMC20E1MD6P  ~/Desktop/minipro/vshow   master  npm run dev:weapp

> vshow@1.0.0 dev:weapp /Users//Desktop/minipro/vshow
> npm run build:weapp -- --watch


> vshow@1.0.0 build:weapp /Users//Desktop/minipro/vshow
> NODE_ENV=production taro build --type weapp "--watch"

👽 Taro v3.0.7

生成  工具配置  /Users//Desktop/minipro/vshow/dist/project.config.json

编译  发现入口  src/app.js
编译  发现页面  src/pages/index/index.jsx
🙅   编译失败.

./src/pages/index/index.jsx)
Module not found: Can't resolve '../../components' in '/Users//Desktop/minipro/vshow/src/pages/index'


监听文件修改中...

./src/pages/index/index.jsx (./node_modules/_babel-loader@8.0.6@babel-loader/lib!./src/pages/index/index.jsx)
Module not found: Error: Can't resolve '../../components' in '/Users//Desktop/minipro/vshow/src/pages/index'
resolve '../../components' in '/Users//Desktop/minipro/vshow/src/pages/index'
  using description file: /Users//Desktop/minipro/vshow/package.json (relative path: ./src/pages/index)
    resolve multi platform file path
      using description file: /Users//Desktop/minipro/vshow/package.json (relative path: ./src/pages/index)
        using description file: /Users//Desktop/minipro/vshow/package.json (relative path: ./src/components)
          no extension
            /Users//Desktop/minipro/vshow/src/components is not a file
          .js
            /Users//Desktop/minipro/vshow/src/components.js doesn't exist
          .jsx
            /Users//Desktop/minipro/vshow/src/components.jsx doesn't exist
          .ts
            /Users//Desktop/minipro/vshow/src/components.ts doesn't exist
          .tsx
            /Users//Desktop/minipro/vshow/src/components.tsx doesn't exist
          .mjs
            /Users//Desktop/minipro/vshow/src/components.mjs doesn't exist
          .vue
            /Users//Desktop/minipro/vshow/src/components.vue doesn't exist
          as directory
            existing directory
              using path: /Users//Desktop/minipro/vshow/src/components/index
                using description file: /Users//Desktop/minipro/vshow/package.json (relative path: ./src/components/index)
                  no extension
                    /Users//Desktop/minipro/vshow/src/components/index doesn't exist
                  .js
                    /Users//Desktop/minipro/vshow/src/components/index.js doesn't exist
                  .jsx
                    /Users//Desktop/minipro/vshow/src/components/index.jsx doesn't exist
                  .ts
                    /Users//Desktop/minipro/vshow/src/components/index.ts doesn't exist
                  .tsx
                    /Users//Desktop/minipro/vshow/src/components/index.tsx doesn't exist
                  .mjs
                    /Users//Desktop/minipro/vshow/src/components/index.mjs doesn't exist
                  .vue
                    /Users//Desktop/minipro/vshow/src/components/index.vue doesn't exist
[/Users//Desktop/minipro/vshow/src/components]
[/Users//Desktop/minipro/vshow/src/components.js]
[/Users//Desktop/minipro/vshow/src/components.jsx]
[/Users//Desktop/minipro/vshow/src/components.ts]
[/Users//Desktop/minipro/vshow/src/components.tsx]
[/Users//Desktop/minipro/vshow/src/components.mjs]
[/Users//Desktop/minipro/vshow/src/components.vue]
[/Users//Desktop/minipro/vshow/src/components/index]
[/Users//Desktop/minipro/vshow/src/components/index.js]
[/Users//Desktop/minipro/vshow/src/components/index.jsx]
[/Users//Desktop/minipro/vshow/src/components/index.ts]
[/Users//Desktop/minipro/vshow/src/components/index.tsx]
[/Users//Desktop/minipro/vshow/src/components/index.mjs]
[/Users//Desktop/minipro/vshow/src/components/index.vue]
 @ ./src/pages/index/index.jsx (./node_modules/_babel-loader@8.0.6@babel-loader/lib!./src/pages/index/index.jsx) 9:0-45 87:44-53
 @ ./src/pages/index/index.jsx


(node:40717) UnhandledPromiseRejectionWarning: [object Array]
(node:40717) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:40717) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
上一篇下一篇

猜你喜欢

热点阅读