uni-app vue-cli 新建的项目运行不起来

fhg3lkii  于 2021-11-27  发布在  Java
关注(0)|答案(9)|浏览(571)

问题描述

vue create -p dcloudio/uni-preset-vue my-project 新建的项目 然后 cd 到 my-project 目录下,执行
npm run dev:mp-weixin 报错跑不起来

复现步骤

[复现问题的步骤]

  1. npm install -g @vue/cli
  2. vue create -p dcloudio/uni-preset-vue my-project
  3. cd my-project
  4. npm run dev:mp-weixin

预期结果

项目能够正常运行

实际结果

/Users/loewe/my-project/node_modules/@dcloudio/uni-cli-shared/lib/platform.js:26
const uniPluginOptions = global.uniPlugin.options || {}
^

TypeError: Cannot read property 'options' of undefined
at Object. (/Users/loewe/my-project/node_modules/@dcloudio/uni-cli-shared/lib/platform.js:26:43)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/Users/loewe/my-project/node_modules/@dcloudio/uni-cli-shared/lib/index.js:60:5)
at Module._compile (internal/modules/cjs/loader.js:776:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.1.0 dev:mp-weixin: cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@0.1.0 dev:mp-weixin script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

系统信息:

uni-app v2.5.1
uni-app cli v2.0.0-alpha-25120200103006

Environment Info:

System:
OS: macOS 10.15.1
CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: Not Found
npm: 6.14.4 - ~/.nvm/versions/node/v10.16.0/bin/npm
Browsers:
Chrome: 80.0.3987.163
Firefox: Not Found
Safari: 13.0.3
npmPackages:
@dcloudio/uni-app-plus: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-cli-shared: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-h5: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-helper-json: * => 1.0.5
@dcloudio/uni-migration: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-mp-alipay: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-mp-baidu: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-mp-qq: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-mp-toutiao: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-mp-weixin: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/uni-stat: ^2.0.0-alpha-25120200103006 => 2.0.0-v3-24020191018001
@dcloudio/uni-template-compiler: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-25120200103006
@dcloudio/vue-cli-plugin-uni: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-25120200103006
@dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-26920200411001
@dcloudio/webpack-uni-mp-loader: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-25120200103006
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: ^2.0.0-alpha-25120200103006 => 2.0.0-alpha-25120200103006
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.1.2
@vue/babel-preset-app: 4.3.1
@vue/babel-preset-jsx: 1.1.2
@vue/babel-sugar-functional-vue: 1.1.2
@vue/babel-sugar-inject-h: 1.1.2
@vue/babel-sugar-v-model: 1.1.2
@vue/babel-sugar-v-on: 1.1.2
@vue/cli-overlay: 4.3.1
@vue/cli-plugin-babel: ~4.3.0 => 4.3.1
@vue/cli-plugin-router: 4.3.1
@vue/cli-plugin-vuex: 4.3.1
@vue/cli-service: ~4.3.0 => 4.3.1
@vue/cli-shared-utils: 4.3.1
@vue/component-compiler-utils: 3.1.2 (3.1.2)
@vue/preload-webpack-plugin: 1.1.1
@vue/web-component-wrapper: 1.2.0
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^2.6.11 => 2.6.11
vue-hot-reload-api: 2.3.4
vue-loader: 15.9.1 (15.9.1)
vue-router: 3.0.1
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.11 => 2.6.11
vue-template-es2015-compiler: 1.9.1
vuex: ^3.0.1 => 3.1.3
npmGlobalPackages:
@vue/cli: 4.3.1

qpgpyjmq

qpgpyjmq1#

你创建的工程里依赖的版本乱掉了,你可以清理一下npm的cache,重新创建一下试试
正常的最新的版本依赖如下:

uni-app v2.6.11
uni-app cli v2.0.0-26920200409002

Environment Info:

  System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
  Binaries:
    Node: 12.15.0 - ~/.nvm/versions/node/v12.15.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.15.0/bin/npm
  Browsers:
    Chrome: 80.0.3987.163
    Firefox: Not Found
    Safari: 13.1
  npmPackages:
    @dcloudio/uni-app-plus: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-app-plus-nvue:  0.0.1 
    @dcloudio/uni-app-plus-nvue-v8:  0.0.1 
    @dcloudio/uni-cli-shared: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-h5: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-helper-json: * => 1.0.5 
    @dcloudio/uni-migration: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-mp-alipay: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-mp-baidu: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-mp-qq: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-mp-toutiao: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-mp-weixin: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-stat: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/uni-template-compiler: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/vue-cli-plugin-uni: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/webpack-uni-mp-loader: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @dcloudio/webpack-uni-nvue-loader:  0.0.1 
    @dcloudio/webpack-uni-pages-loader: ^2.0.0-26920200409002 => 2.0.0-26920200409002 
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.3.1 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.3.1 
    @vue/cli-plugin-babel: ~4.3.0 => 4.3.1 
    @vue/cli-plugin-router:  4.3.1 
    @vue/cli-plugin-vuex:  4.3.1 
    @vue/cli-service: ~4.3.0 => 4.3.1 
    @vue/cli-shared-utils:  4.3.1 
    @vue/component-compiler-utils:  3.1.2 (3.1.2)
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    mpvue-page-factory:  1.0.1 
    mpvue-template-compiler:  1.0.13 
    uni-h5-vue:  2.6.10 
    uni-mp-vue:  2.6.10 
    vue: ^2.6.11 => 2.6.11 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.1 (15.9.1)
    vue-router:  3.0.1 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.0.1 => 3.1.3 
  npmGlobalPackages:
    @vue/cli: 4.2.3

package.json

{
  "name": "my-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "npm run dev:h5",
    "build": "npm run build:h5",
    "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
    "build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
    "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
    "build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
    "build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
    "build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
    "build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
    "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
    "build:quickapp": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp vue-cli-service uni-build",
    "dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
    "dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
    "dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
    "dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
    "dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
    "dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
    "dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
    "dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
    "dev:quickapp": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp vue-cli-service uni-build --watch",
    "info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
    "serve:quickapp": "node node_modules/@dcloudio/uni-quickapp/bin/serve.js"
  },
  "dependencies": {
    "@dcloudio/uni-app-plus": "^2.0.0-26920200409002",
    "@dcloudio/uni-h5": "^2.0.0-26920200409002",
    "@dcloudio/uni-helper-json": "*",
    "@dcloudio/uni-mp-alipay": "^2.0.0-26920200409002",
    "@dcloudio/uni-mp-baidu": "^2.0.0-26920200409002",
    "@dcloudio/uni-mp-qq": "^2.0.0-26920200409002",
    "@dcloudio/uni-mp-toutiao": "^2.0.0-26920200409002",
    "@dcloudio/uni-mp-weixin": "^2.0.0-26920200409002",
    "@dcloudio/uni-stat": "^2.0.0-26920200409002",
    "core-js": "^3.6.4",
    "flyio": "^0.6.2",
    "regenerator-runtime": "^0.12.1",
    "vue": "^2.6.11",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@dcloudio/uni-cli-shared": "^2.0.0-26920200409002",
    "@dcloudio/uni-migration": "^2.0.0-26920200409002",
    "@dcloudio/uni-template-compiler": "^2.0.0-26920200409002",
    "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.0-26920200409002",
    "@dcloudio/vue-cli-plugin-uni": "^2.0.0-26920200409002",
    "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-26920200409002",
    "@dcloudio/webpack-uni-mp-loader": "^2.0.0-26920200409002",
    "@dcloudio/webpack-uni-pages-loader": "^2.0.0-26920200409002",
    "@types/html5plus": "*",
    "@types/uni-app": "*",
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "babel-plugin-import": "^1.11.0",
    "cross-env": "^7.0.2",
    "mini-types": "*",
    "miniprogram-api-typings": "^2.8.0-2",
    "postcss-comment": "^2.0.0",
    "vue-template-compiler": "^2.6.11"
  },
  "browserslist": [
    "Android >= 4",
    "ios >= 8"
  ],
  "uni-app": {
    "scripts": {}
  }
}
hvvq6cgz

hvvq6cgz2#

@fxy060608

清除了缓存也还是无效呢,报相同的错误。ps: 我还更新了 node 版本,也是无效

nhhxz33t

nhhxz33t3#

你的npm仓库,是标准的,还是cnpm的(taobao)的?换标准的,或者安装使用yarn

3duebb1j

3duebb1j4#

试了还是不行,npm 是标准的,没用 cnpm; yarn 试了也不行

vvppvyoh

vvppvyoh6#

怎么解决的最后

u1ehiz5o

u1ehiz5o7#

我也出现了,怎么解决的???

wnavrhmk

wnavrhmk8#

重新安装依赖试试

cunj1qz1

cunj1qz19#

我也遇到了 全局的cross-env卸载重装一下就好了

相关问题