问题描述
vue create -p dcloudio/uni-preset-vue my-project 新建的项目 然后 cd 到 my-project 目录下,执行
npm run dev:mp-weixin 报错跑不起来
复现步骤
[复现问题的步骤]
- npm install -g @vue/cli
- vue create -p dcloudio/uni-preset-vue my-project
- cd my-project
- 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
9条答案
按热度按时间qpgpyjmq1#
你创建的工程里依赖的版本乱掉了,你可以清理一下npm的cache,重新创建一下试试
正常的最新的版本依赖如下:
package.json
hvvq6cgz2#
@fxy060608
清除了缓存也还是无效呢,报相同的错误。ps: 我还更新了 node 版本,也是无效
nhhxz33t3#
你的npm仓库,是标准的,还是cnpm的(taobao)的?换标准的,或者安装使用yarn
3duebb1j4#
试了还是不行,npm 是标准的,没用 cnpm; yarn 试了也不行
ui7jx7zq5#
vvppvyoh6#
怎么解决的最后
u1ehiz5o7#
我也出现了,怎么解决的???
wnavrhmk8#
重新安装依赖试试
cunj1qz19#
我也遇到了 全局的cross-env卸载重装一下就好了