请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册
搜索

开发问题 升级 1040 版本后出错

2
回复
98
查看
[复制链接]

4

主题

10

帖子

70

积分

 楼主| 2019-5-8 14:26:53 显示全部楼层 |阅读模式
升级过程问题多多,升级后出现报错。
这个是我的 package.json 的依赖:
  1.   "devDependencies": {
  2.     "babel-cli": "^6.10.1",
  3.     "babel-core": "^6.26.0",
  4.     "babel-eslint": "^8.2.1",
  5.     "babel-loader": "^8.0.5",
  6.     "babel-plugin-syntax-jsx": "^6.18.0",
  7.     "cross-env": "^5.1.4",
  8.     "css-what": "^2.1.0",
  9.     "hap-toolkit": "0.4.3",
  10.     "less": "^3.8.1",
  11.     "less-loader": "^4.1.0"
  12.   },
复制代码
这个是调试窗口的错误:
34A72BD2-946B-42B4-9834-03FCC8F07E77.png
  1. {"fileName":"undefined","pageName":"PageList","functionName":"createPage","remarks":"PageList\/index.js","line":1029,"startColumn":0,"endColumn":1,"jsMessage":"Error: Module build failed (from .\/node_modules\/babel-loader\/lib\/index.js):\nError: ENOENT: no such file or directory, open '\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/.babelrc'\n    at Object.openSync (fs.js:438:3)\n    at Object.readFileSync (fs.js:343:35)\n    at ConfigChainBuilder.addConfig (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:146:32)\n    at ConfigChainBuilder.findConfigs (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:96:16)\n    at buildConfigChain (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:61:13)\n    at OptionManager.init (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/option-manager.js:354:58)\n    at File.initOptions (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/index.js:212:65)\n    at new File (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/index.js:135:24)\n    at Pipeline.transform (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/pipeline.js:46:16)\n    at transpile (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-loader\/lib\/index.js:50:20)","stackTrace":"Error: Module build failed (from .\/node_modules\/babel-loader\/lib\/index.js):\nError: ENOENT: no such file or directory, open '\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/.babelrc'\n    at Object.openSync (fs.js:438:3)\n    at Object.readFileSync (fs.js:343:35)\n    at ConfigChainBuilder.addConfig (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:146:32)\n    at ConfigChainBuilder.findConfigs (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:96:16)\n    at buildConfigChain (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/build-config-chain.js:61:13)\n    at OptionManager.init (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/options\/option-manager.js:354:58)\n    at File.initOptions (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/index.js:212:65)\n    at new File (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/file\/index.js:135:24)\n    at Pipeline.transform (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-core\/lib\/transformation\/pipeline.js:46:16)\n    at transpile (\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/babel-loader\/lib\/index.js:50:20)\n    at Object..\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/script-loader.js!.\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/module-loader.js!.\/node_modules\/babel-loader\/lib\/index.js?cwd=\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP&plugins[]=\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/babel-plugin-jsx.js&comments=false!.\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/fragment-loader.js?index=0&type=script!.\/src\/components\/TitleBar.ux?uxType=comp (eval at Ln (native.js:3:178), <anonymous>:1029:7)\n    at __webpack_require__ (eval at Ln (native.js:3:178), <anonymous>:25:30)\n    at Object..\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/ux-loader.js?cwd=\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP&type=import!.\/src\/components\/TitleBar.ux?uxType=comp&name=title-bar (eval at Ln (native.js:3:178), <anonymous>:1064:20)\n    at __webpack_require__ (eval at Ln (native.js:3:178), <anonymous>:25:30)\n    at Object..\/src\/PageList\/index.ux?uxType=page (eval at Ln (native.js:3:178), <anonymous>:1131:1)\n    at __webpack_require__ (eval at Ln (native.js:3:178), <anonymous>:25:30)\n    at .\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/json-loader.js!.\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/style-loader.js?index=0&type=style!.\/node_modules\/@hap-toolkit\/dsl-xvm\/lib\/loader\/fragment-loader.js?index=0&type=style!.\/src\/components\/qapp\/qui-button\/index.ux?uxType=comp.module.exports..qui-button-box.width (eval at Ln (native.js:3:178), <anonymous>:89:18)\n    at createPageHandler (eval at Ln (native.js:3:178), <anonymous>:92:10)\n    at eval (eval at Ln (native.js:3:178), <anonymous>:1155:12)\n    at eval (eval at Ln (native.js:3:178), <anonymous>:1160:3)","className":"com.eclipsesource.v8.V8ScriptExecutionException","jsScript":"throw new Error("Module build failed (from .\/node_modules\/babel-loader\/lib\/index.js):\\nError: ENOENT: no such file or directory, open '\/Users\/mazhaokeng\/project-orvibo\/Oppo-IoT-QuickAPP\/.babelrc'\\n  "}
复制代码
请问要怎么解决?
回复

使用道具 举报

10

主题

147

帖子

835

积分

2019-5-8 17:05:27 显示全部楼层
#### 一、从小于 0.0.38 版本升级

若 hap-toolkit 从 0.0.37 升级上来,有比较大的改动,其中需要注意的是:

1. 项目下面的 .babelrc 文件变更为 babel.config.js 文件。babel.config.js 内容如:

```
module.exports = function(api) {
  api.cache(true)
  return {
    presets: ['@babel/preset-env'],
    plugins: ['@babel/plugin-transform-modules-commonjs'],
    babelrcRoots: ['.', 'node_modules']
  }
}
```

**.babelrc 文件需要删除。**

2. 项目的基础依赖只需要以下模块,package.json 里的 devDependencies 字段如:

```
{
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "eslint": "^5.12.1",
    "eslint-plugin-hybrid": "0.0.5",
    "hap-toolkit": "^0.4.3"
  }
}
```
**修改后请将 node_modules 和 package-lock.json 删除,再重新安装依赖。**
回复

使用道具 举报

4

主题

10

帖子

70

积分

 楼主| 2019-5-10 16:52:42 显示全部楼层
好的已经修复
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册