• 解决:TypeError: initAutoImportComponents is not a function 过程记录


    PS F:Workspacevscodeuser_uniapp> npm run build:h5
    
    > xiaoti@0.1.0 build:h5 F:Workspacevscodeuser_uniapp
    > cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build
    
    
    当前应用未配置Appid,无法使用uni统计,详情参考:https://ask.dcloud.net.cn/article/36303
    
    F:Workspacevscodeuser_uniapp
    ode_modules@dcloudiovue-cli-plugin-unilibenv.js:318
    initAutoImportComponents(pagesJsonObj.easycom)
    ^
    
    TypeError: initAutoImportComponents is not a function
        at Object.<anonymous> (F:Workspacevscodeuser_uniapp
    ode_modules@dcloudiovue-cli-plugin-unilibenv.js:318:1)
        at Module._compile (internal/modules/cjs/loader.js:955:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
        at Module.load (internal/modules/cjs/loader.js:811:32)
        at Function.Module._load (internal/modules/cjs/loader.js:723:14)
        at Module.require (internal/modules/cjs/loader.js:848:19)
        at require (internal/modules/cjs/helpers.js:74:18)
        at Object.<anonymous> (F:Workspacevscodeuser_uniapp
    ode_modules@dcloudiovue-cli-plugin-uniindex.js:6:5)
        at Module._compile (internal/modules/cjs/loader.js:955:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! xiaoti@0.1.0 build:h5: `cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the xiaoti@0.1.0 build:h5 script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:UsersDELLAppDataRoaming
    pm-cache\_logs2020-02-10T05_43_14_338Z-debug.log

    解决:

    1.检查package.json版本,如下:

    "devDependencies": {
        "@dcloudio/uni-cli-shared": "0.2.994",
        "@dcloudio/uni-template-compiler": "0.9.179",
        "@dcloudio/vue-cli-plugin-hbuilderx": "2.0.0-24220191115011",
        "@dcloudio/vue-cli-plugin-uni": "2.0.0-24220191115011",
        "@dcloudio/webpack-uni-mp-loader": "^0.3.637",
        "@dcloudio/webpack-uni-pages-loader": "^0.2.845",
        "@types/html5plus": "*",
        "@types/uni-app": "1.2.0",
        "@vue/cli-plugin-babel": "3.5.1",
        "@vue/cli-service": "3.12.1",
        "babel-plugin-import": "^1.12.0",
        "vue-template-compiler": "^2.5.21",
        "weex-vue-loader": "^0.7.0"
      },

    2.删除package-lock.json,npm install 重新下载依赖

    报错(具体报错代码暂无,npm install后package-lock.json并未下载,另还有其他报错信息)

    解决:

    npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

    报错:

    ERROR Failed to compile with 1 errors 18:12:37
    error in ./node_modules/@dcloudio/uni-ui/lib/uni-number-box/uni-number-box.vue?vue&type=style&index=0&id=a0240016&lang=scss&scoped=true&

    Module build failed (from ./node_modules/sass-loader/dist/cjs.js):

    border: 1px solid $uni-border-color;
    ^
    Undefined variable: "$uni-border-color".
    in F:Workspacevscodeuser_uniapp ode_modules@dcloudiouni-uilibuni-number-boxuni-number-box.vue (line 128, column 21)
    @ ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue-style-loader??ref--8-oneOf-1-0!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--8-oneOf-1-1!./node_modules/css-loader??ref--8-oneOf-1-2!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-3!./node_modules/postcss-loader/src??ref--8-oneOf-1-4!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-5!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--8-oneOf-1-6!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader??ref--0-1!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader!./node_modules/@dcloudio/uni-ui/lib/uni-number-box/uni-number-box.vue?vue&type=style&index=0&id=a0240016&lang=scss&scoped=true& 4:14-767
    @ ./node_modules/@dcloudio/uni-ui/lib/uni-number-box/uni-number-box.vue?vue&type=style&index=0&id=a0240016&lang=scss&scoped=true& @ ./node_modules/@dcloudio/uni-ui/lib/uni-number-box/uni-number-box.vue
    @ ./node_modules/babel-loader/lib!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--12-1!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--16-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader??ref--0-1!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader!./src/pagesA/order/affirmOrderAgain.vue?vue&type=script&lang=js&
    @ ./src/pagesA/order/affirmOrderAgain.vue?vue&type=script&lang=js&
    @ ./src/pagesA/order/affirmOrderAgain.vue
    @ ./src/pages.json
    @ ./src/main.js
    @ multi ./src/main.js

    ERROR Build failed with errors.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! xiaoti@0.1.0 build:h5: `cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the xiaoti@0.1.0 build:h5 script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:UsersDELLAppDataRoaming pm-cache\_logs2020-02-10T10_12_39_974Z-debug.log

    错误原因:$uni-border-color未定义

    解决:

    在依赖中定义$uni-border-color:#c8c7cc;(具体颜色代码参照uni.scss文件中的定义)

    之后运行可能还会报类似错误,只要把未定义的代码都定义了就ok啦!

    我这边先后加了如下样式:

     $uni-border-color:#c8c7cc;
      $uni-bg-color:#ffffff;
      $uni-border-radius-lg:12upx;
      $uni-text-color:#333;//基本色
      $uni-bg-color-grey:f8f8f8;
      $uni-text-color-disable:#c0c0c0;

    ok!

    这种方法感觉不是特别好,但能解决当前问题,小伙伴们有什么好方法评论区见哈

  • 相关阅读:
    Educational Codeforces Round 67 D. Subarray Sorting
    2019 Multi-University Training Contest 5
    Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code
    Educational Codeforces Round 69 D. Yet Another Subarray Problem
    2019牛客暑期多校训练第六场
    Educational Codeforces Round 68 E. Count The Rectangles
    2019牛客多校第五场题解
    2019 Multi-University Training Contest 3
    2019 Multi-University Training Contest 2
    [模板] 三维偏序
  • 原文地址:https://www.cnblogs.com/mfbzr/p/12292001.html
Copyright © 2020-2023  润新知