Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

when use command weex compile case error /node_modules/weex-ui/index.js Module build failed: Error: Cannot find module 'babel-core' #137

Closed
@songxing10000

Description

@songxing10000

根据官方命令安装环境

brew install node
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g weex-toolkit@latest

然后环境为
image
然后weex create UUU
然后进入项目
npm i weex-ui@latest -S
npm i babel-plugin-component babel-preset-stage-0 -D
修改文件.babelrc

{
  "presets": ["es2015", "stage-0"],
  "plugins": [
    [
      "component",
      {
        "libraryName": "weex-ui",
        "libDir": "packages",
        "style": false
      }
    ]
  ]
}

导入组件

<script>
  import { WxcLightbox } from 'weex-ui';
  export default {
    components: {
      WxcLightbox
    },
    ....

使用组件

<template>
  <div class="container">
    <wxc-lightbox
      height="100"
      :show="show"
      :image-list="imageList"
      @wxcLightboxOverlayClicked="wxcLightboxOverlayClicked">
    </wxc-lightbox>
    ...

然后执行命令weex compile src /usr/local/var/www用来把js文件放到nginx上,结果报错

image
试了npm装,cnpm装,都报错
/node_modules/weex-ui/index.js Module build failed: Error: Cannot find module 'babel-core'

Activity

songxing10000

songxing10000 commented on Jan 28, 2018

@songxing10000
Author

@tw93 所有操作都是按那个文档来的,npm run serve能界面正常,为啥执行命令weex compile src /usr/local/var/www用来把js文件放到nginx上,就会提示
/node_modules/weex-ui/index.js Module build failed: Error: Cannot find module 'babel-core'

tw93

tw93 commented on Jan 28, 2018

@tw93
Member

Try

npm install babel-core babel-loader -D
songxing10000

songxing10000 commented on Jan 31, 2018

@songxing10000
Author

已解决,将文件/usr/local/lib/node_modules下的weex-toolkit反复删除,反复执行npm install -g weex-toolkit@latest就正常了,因为之前已经在项目里执行过了命令npm i npm i weex-ui@latest -S npm i babel-plugin-component babel-preset-stage-0 -D 同时修改.babelrc,所以命令npm install -g weex-toolkit@latest是关键
image

liangklfangl

liangklfangl commented on Mar 14, 2018

@liangklfangl

这个反复两个字用的好,到底是多少次算反复?

liangklfangl

liangklfangl commented on Mar 14, 2018

@liangklfangl

其实解决方案在这里。因为weex-toolkit全局安装的时候将babel-core设置了devDependencies,所以导致全局安装的时候并不会主动安装它,所以找不到这个模块,你可以看看weex-toolkit的package.json。建议官方修复下这个问题~~~

songxing10000

songxing10000 commented on Jun 5, 2018

@songxing10000
Author

又报这个错了weex build failed: Error: Cannot find module \'babel-core\'\n at
解决方案还是
将文件/usr/local/lib/node_modules下的weex-toolkit删除,
执行npm install -g weex-toolkit@latest就正常了,
然后 删除项目里的node_modules
然后执行cnpm install ,并没有执行
npm i npm i weex-ui@latest -S npm i babel-plugin-component babel-preset-stage-0 -D也是编译成功的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tw93@songxing10000@liangklfangl

        Issue actions

          when use command weex compile case error /node_modules/weex-ui/index.js Module build failed: Error: Cannot find module 'babel-core' · Issue #137 · apache/incubator-weex-ui