weex icon indicating copy to clipboard operation
weex copied to clipboard

weex-toolkit 出现异常

Open vczero opened this issue 10 years ago • 15 comments

原因:weex-toolkit最新版本无法使用weex xxx.we命令,会出现异常。因此,这里给开发者两个方案可选。

第一种方法:安装0.4.0版本(推荐)

npm install -g [email protected]

后面直接使用即可。

第二种方法:安装依赖 把提示出现缺少的依赖安装了。具体可以先在目录下新建package.json文件,里面内容为:

{
  "name": "test",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-runtime": "^6.11.6",
    "serve": "^1.4.0",
    "webpack": "^1.13.1",
    "weex-html5": "^0.3.0",
    "weex-loader": "^0.3.1"
  }
}

然后执行:

npm install

最后命令正常使用了。

vczero avatar Sep 13 '16 07:09 vczero

@Jinjiang @luics @lvscar

vczero avatar Sep 13 '16 07:09 vczero

请保持,勿关闭。

vczero avatar Sep 13 '16 07:09 vczero

Run npm install babel-plugin-transform-runtime --save-dev on the project directory. Bug fixed:

ERR! ModuleBuildError: Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified in "base" at 0, attempted to resolve relative to undefined
    at /usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:195:17
    at Array.map (native)
    at Function.normalisePlugins (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:175:20)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:273:36)
    at OptionManager.init (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:414:10)
    at File.initOptions (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/index.js:191:75)
    at new File (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/index.js:122:22)
    at Pipeline.transform (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
    at transpile (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-loader/index.js:38:20)
    at Object.module.exports (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-loader/index.js:131:12) 
ERR! ReferenceError: Unknown plugin "transform-runtime" specified in "base" at 0, attempted to resolve relative to undefined 

zhoukekestar avatar Sep 18 '16 06:09 zhoukekestar

最新的 weex-toolkit 0.5.1 修复该问题了,请使用 cnpm install [email protected] -g 进行升级

lvscar avatar Sep 18 '16 13:09 lvscar

很多人用0.5.2版本,执行weex main,we命令报错

jiangfei891111 avatar Sep 20 '16 06:09 jiangfei891111

开来还是有问题,有必要继续深入排查一下

Jinjiang avatar Sep 20 '16 12:09 Jinjiang

我试了0.51,问题还是存在。现在降回0.4了

StanNing avatar Sep 21 '16 03:09 StanNing

@vczero 按照要求,weexone目录下写了package.json,并且npm install安装成功。

weex *.we --qr的时候还是出现错误

psychokiller:WeexOne user$ weex --version
info 0.5.2
psychokiller:WeexOne user$ cat package.json
{
  "name": "test",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-runtime": "^6.11.6",
    "serve": "^1.4.0",
    "webpack": "^1.13.1",
    "weex-html5": "^0.3.0",
    "weex-loader": "^0.3.1"
  }
}
psychokiller:WeexOne user$ weex index.we index.we
ERR! ModuleBuildError: Module build failed: ReferenceError: Unknown plugin "/usr/local/lib/node_modules/weex-toolkit/node_modules/weex-loader/node_modules/babel-plugin-transform-runtime" specified in "base" at 0, attempted to resolve relative to "/Users/user/workspace/weex/WeexOne"
    at /usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:172:17
    at Array.map (native)
    at Function.normalisePlugins (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:150:20)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:224:36)
    at OptionManager.init (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:338:12)
    at File.initOptions (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/index.js:216:65)
    at new File (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/file/index.js:137:24)
    at Pipeline.transform (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-loader/index.js:38:20)
    at Object.module.exports (/usr/local/lib/node_modules/weex-toolkit/node_modules/babel-loader/index.js:131:12)
ERR! ReferenceError: Unknown plugin "/usr/local/lib/node_modules/weex-toolkit/node_modules/weex-loader/node_modules/babel-plugin-transform-runtime" specified in "base" at 0, attempted to resolve relative to "/Users/user/workspace/weex/WeexOne"
psychokiller:WeexOne user$

psychokiller666 avatar Sep 21 '16 03:09 psychokiller666

把weex-loader 降级为0.3.1版本就可以了,0.3.2会报所示错误 @psychokiller666

SimonTal avatar Sep 21 '16 08:09 SimonTal

是的,降低weex-loader的版本(目前的0.3.2的依赖因为weex本身的依赖而跳过了)

还有另外的办法是手动安装weex-loader(0.3.2版本)的依赖: mkdir node_modules/weex-loader/node_modules/ cp -R node_modules/babel-plugin-transform-runtime node_modules/weex-loader/node_modules/ cp -R node_modules/babel-preset-es2015 node_modules/weex-loader/node_modules/

tangseng avatar Sep 21 '16 08:09 tangseng

@SimonTal 你的方法我用了,可以。用楼下 @tangseng 的方法也可以,谢谢😊

psychokiller666 avatar Sep 22 '16 08:09 psychokiller666

@tangseng @psychokiller666 @SimonTal @StanNing 请试一下最新的 [email protected] 看看这个问题在你们的场景下还会出现吗?

lvscar avatar Sep 23 '16 08:09 lvscar

seems latest weex-loader fix works. thx @dickeylth

lvscar avatar Sep 26 '16 02:09 lvscar

$ weex -v [17:30:52] v1.0.0-beta.1

  • weex-builder : v0.1.8

$ weex index.we [17:30:58] [ '/home/tim/.nvm/versions/node/v7.1.0/bin/node', '/home/tim/.nvm/versions/node/v7.1.0/lib/node_modules/.weex-toolkit_npminstall/node_modules/.1.0.0-beta.1@weex-toolkit/src/weex-preview.js', 'index.we' ] { Error: Cannot find module 'babel-runtime/core-js/promise' at Function.Module._resolveFilename (module.js:472:15) at Function.Module._load (module.js:420:25) at Module.require (module.js:500:17) at require (internal/module.js:20:19) at Object. (/home/tim/.nvm/versions/node/v7.1.0/lib/node_modules/.weex-toolkit_npminstall/node_modules/.1.0.4@weex-previewer/build/index.js:3:16) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) at Module.load (module.js:490:32) at tryModuleLoad (module.js:449:12) at Function.Module._load (module.js:441:3) code: 'MODULE_NOT_FOUND' } Error: Cannot find module 'babel-runtime/core-js/promise' at Function.Module._resolveFilename (module.js:472:15) at Function.Module._load (module.js:420:25) at Module.require (module.js:500:17) at require (internal/module.js:20:19) at Object. (/home/tim/.nvm/versions/node/v7.1.0/lib/node_modules/.weex-toolkit_npminstall/node_modules/.1.0.4@weex-previewer/build/index.js:3:16) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) at Module.load (module.js:490:32) at tryModuleLoad (module.js:449:12) at Function.Module._load (module.js:441:3)

Tim2011 avatar Jan 10 '17 09:01 Tim2011

@Tim2011 是包依赖的问题,您可以先降级安装下,weex-toolkit新版本还在测试中

npm install [email protected] -g

JackPu avatar Jan 10 '17 14:01 JackPu