Open w3286879 opened 5 years ago
看一下 @wepy/compiler-less 的版本。 使用最新的版本试一下。
那天已经更新了最新版本还是不行,我后面在外层加了个判断了。
看一下 @wepy/compiler-less 的版本。 使用最新的版本试一下。
"dependencies": { "@wepy/x": "^2.0.2", "@wepy/core": "^2.0.0-alpha.9", "miniprogram-slide-view": "0.0.3" }, "devDependencies": { "@wepy/cli": "^2.0.0-alpha.10", "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@wepy/babel-plugin-import-regenerator": "0.0.2", "babel-eslint": "^7.2.1", "cross-env": "^5.1.3", "less": "^3.8.1", "@wepy/compiler-babel": "^2.0.1", "@wepy/compiler-less": "^2.0.1" }
我把这里面列出来的全都更新了一遍,仍然不行
那天已经更新了最新版本还是不行,我后面在外层加了个判断了。
用这个命令npm install @wepy/cli@next -g 就好了,不要用官方文档上的npm install @wepy/cli -g
@Gcaufy 按照 https://wepyjs.github.io/wepy-docs/2.x/#/base/getstart 说明,在 Mac 中执行如下命令
$ npm install @wepy/cli -g
$ wepy init standard myproj
$ cd myproj
$ npm install
$ npm run dev
报错
我的也报错!
那天已经更新了最新版本还是不行,我后面在外层加了个判断了。
用这个命令npm install @wepy/cli@next -g 就好了,不要用官方文档上的npm install @wepy/cli -g
用这个也不行,依然报错Cannot read property 'addDeps' of undefined (Win64)
MeToo Cannot read property 'addDeps' of undefined
v10.15.3
6.10.3
{ "name": "aaa", "version": "0.0.2", "description": "description", "main": "weapp/app.js", "scripts": { "dev": "./node_modules/.bin/wepy build --watch", "build": "cross-env NODE_ENV=production ./node_modules/.bin/wepy build --no-cache", "clean": "rm -rf weapp", "test": "echo \"Error: no test specified\" && exit 1" }, "wepy": { "module-a": false, "./src/components/list": "./src/components/wepy-list.wpy" }, "author": "author", "license": "MIT", "dependencies": { "@wepy/x": "^2.0.2", "@wepy/core": "^2.0.0-alpha.9", "miniprogram-slide-view": "0.0.3" }, "devDependencies": { "@wepy/cli": "^2.0.0-alpha.10", "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@wepy/babel-plugin-import-regenerator": "0.0.2", "babel-eslint": "^7.2.1", "cross-env": "^5.1.3", "eslint": "^3.18.0", "eslint-config-standard": "^7.1.0", "eslint-friendly-formatter": "^2.0.7", "eslint-plugin-html": "^2.0.1", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^2.0.1", "wepy-eslint": "^1.5.3", "less": "^3.8.1", "@wepy/compiler-babel": "^2.0.1", "@wepy/compiler-less": "^2.0.1" } }
"less": "^3.8.1",
"@wepy/compiler-less": "^2.0.1"
npm install @wepy/cli@next -g wepy init standard myproject cd myproject npm install wepy build --watch
注意:不要用npm run dev
npm install @wepy/cli@next -g wepy init standard myproject cd myproject npm install wepy build --watch
注意:不要用npm run dev
我没run dev一样不行,2.0还在alpha版本,估计还有不少问题,但是官方文档就直接运行不了,这太不应该了,让人很失望。@next只是从@wepy/cli@2.0.0-alpha.17升级到了@wepy/cli@2.0.0-alpha.19
npm install @wepy/cli@next -g wepy init standard myproject cd myproject npm install wepy build --watch 注意:不要用npm run dev
我没run dev一样不行,2.0还在alpha版本,估计还有不少问题,但是官方文档就直接运行不了,这太不应该了,让人很失望。@next只是从@wepy/cli@2.0.0-alpha.17升级到了@wepy/cli@2.0.0-alpha.19
试一下用12.10版本的nodejs
npm install @wepy/cli@next -g wepy init standard myproject cd myproject npm install wepy build --watch 注意:不要用npm run dev
我没run dev一样不行,2.0还在alpha版本,估计还有不少问题,但是官方文档就直接运行不了,这太不应该了,让人很失望。@next只是从@wepy/cli@2.0.0-alpha.17升级到了@wepy/cli@2.0.0-alpha.19
试一下用12.10版本的nodejs
我理解错了,是npm run dev指令有问题,使用wepy build --watch正常编译(node也升级到12了,貌似没有相关性),谢谢。
可参考我的版本设置,改动了@wepy/compiler-less和@wepy/cli的版本,运行正常 "name": "myproject", "version": "0.0.2", "description": "A WePY project", "main": "weapp/app.js", "scripts": { "dev": "./node_modules/.bin/wepy build --watch", "build": "cross-env NODE_ENV=production ./node_modules/.bin/wepy build --no-cache", "clean": "rm -rf weapp", "test": "echo \"Error: no test specified\" && exit 1" }, "wepy": { "module-a": false, "./src/components/list": "./src/components/wepy-list.wpy" }, "author": "chenxiaohui chenxiaohui@manqian.com.cn", "license": "MIT", "dependencies": { "@wepy/x": "^2.0.2", "@wepy/core": "^2.0.0-alpha.9", "miniprogram-slide-view": "0.0.3" }, "devDependencies": { "@wepy/cli": "^2.0.0-alpha.19", "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@wepy/babel-plugin-import-regenerator": "0.0.2", "babel-eslint": "^7.2.1", "cross-env": "^5.1.3", "eslint": "^3.18.0", "eslint-config-standard": "^7.1.0", "eslint-friendly-formatter": "^2.0.7", "eslint-plugin-html": "^2.0.1", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^2.0.1", "wepy-eslint": "^1.5.3", "less": "^3.8.1", "@wepy/compiler-babel": "^2.0.3", "@wepy/compiler-less": "^2.0.6" } }
运行结果 [16:17:21] info build app start... [16:17:22] info app building App [16:17:22] info component building components [16:17:23] info component building components [16:17:23] info component building components [16:17:23] info vendor building vendor [16:17:23] info assets building assets [16:17:23] info build finished [16:17:23] info watching...
npm install @wepy/cli@next -g 修改package.json,这行是关键,才能使用上新版wepy "@wepy/cli": "^2.0.0-alpha.19",
@geek945 确实是版本问题,我参考你的package.json ,修改了一下,可以正常运行。谢谢分享 !
官网的推荐的安装方式,都出错,这也太糊弄认了吧
更改之后 依旧报错 怎么解决的?谢谢 { "name": "myproj", "version": "0.0.2", "description": "A WePY project", "main": "weapp/app.js", "scripts": { "dev": "./node_modules/.bin/wepy build --watch", "build": "cross-env NODE_ENV=production ./node_modules/.bin/wepy build --no-cache", "clean": "rm -rf weapp", "test": "echo \"Error: no test specified\" && exit 1" }, "wepy": { "module-a": false, "./src/components/list": "./src/components/wepy-list.wpy" }, "author": "", "license": "MIT", "dependencies": { "@wepy/x": "^2.0.2", "@wepy/core": "^2.0.0-alpha.9", "miniprogram-slide-view": "0.0.3" }, "devDependencies": { "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@wepy/babel-plugin-import-regenerator": "0.0.2", "@wepy/cli": "^2.0.0-alpha.19", "@wepy/compiler-babel": "^2.0.3", "@wepy/compiler-less": "^2.0.6", "babel-eslint": "^7.2.1", "cross-env": "^5.1.3", "less": "^3.8.1" } }
同样报错,按照@lvxiang15 使用npm install @wepy/cli@next -g后成功。
这个问题已经过去,一个多月了。但是官方因该还妥善的解决,不然我也不会遇到这个bug了。
可能有些人遇到的bug如上图,但我遇到是如下图这样的bug
刚开始遇到这个bug,我也到上git上来查,图一的bug明显是出在了某个less文件上,图二就不是那么明显了,所以一开始,我并没有按照图一网友给出的思路去处理bug.
后来我看到了这个版本的解决办法,去相应文件夹查看,发现可能是因为版本迭代,这个bug已经被修复了,补充:我现在的版本是"@wepy/cli": "^2.0.0-alpha.20".
再后来有网友所到package.json中修改"@wepy/compiler-less": "^2.0.0"为"@wepy/compiler-less": "^2.0.6",无果。
于是我有尝试了另一种说法
终于获得了成功,nice.
可是我又遇到了另一个bug
说的是项目下没有staic文件夹,于是我手动添加了一个空的staic文件夹,于是,问题得到了解决,
但是,具体有没有什么后遗症我也不知道,如果谁又更好的解法,欢迎附文,谢谢给与答案的各位网友。附上我的package.json配置,只是修改了 "@wepy/compiler-less": "2.0.3"
{ "name": "myproject3", "version": "0.0.2", "description": "A WePY project", "main": "weapp/app.js", "scripts": { "dev": "./node_modules/.bin/wepy build --watch", "build": "cross-env NODE_ENV=production ./node_modules/.bin/wepy build --no-cache", "clean": "rm -rf weapp", "test": "echo \"Error: no test specified\" && exit 1" }, "wepy": { "module-a": false, "./src/components/list": "./src/components/wepy-list.wpy" }, "author": "", "license": "MIT", "dependencies": { "@wepy/core": "^2.0.0-alpha.9", "miniprogram-slide-view": "0.0.3" }, "devDependencies": { "@wepy/cli": "^2.0.0-alpha.20", "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@wepy/babel-plugin-import-regenerator": "0.0.2", "babel-eslint": "^7.2.1", "cross-env": "^5.1.3", "eslint": "^3.18.0", "eslint-config-standard": "^7.1.0", "eslint-friendly-formatter": "^2.0.7", "eslint-plugin-html": "^2.0.1", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^2.0.1", "wepy-eslint": "^1.5.3", "less": "^3.8.1", "@wepy/compiler-babel": "^2.0.1", "@wepy/compiler-less": "2.0.3" } }
同楼上,试过更新@wepy/compiler-less版本未2.0.6还是不行,
然后 npm install @wepy/cli@next -g
再然后npm i @wepy/cli@2.0.0-alpha.20 --save
,可以了
我的配置:node version: 12.6.0 可以的 package.json:
"dependencies": {
"@wepy/cli": "^2.0.0-alpha.20",
"@wepy/core": "^2.0.0-alpha.9"
},
"devDependencies": {
"@wepy/compiler-babel": "^2.0.3",
"@wepy/compiler-less": "^2.0.3",
"less": "^3.8.1",
"babel-eslint": "^7.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.1.3"
}
但是会报warning Missing wepy entry. A .wpy file should have "wepy.app", "wepy.page" or "wepy.component"
,我是init 的 empty模板.
npm install @wepy/cli@next -g wepy init standard myproject cd myproject npm install wepy build --watch
注意:不要用npm run dev
完整的npm run dev命令应该是:npm run dev: wepy build --watch
我的理解是:npm run dev
和 直接使用wepy build --watch
不一致的原因是因为npm run dev
是package.json中的script,使用的是当前目录中./node_modules/.bin/wepy执行命令,而wepy build --watch
使用的是全局的wepy命令执行,这两个执行文件不是同一个执行文件。
参考http://www.ruanyifeng.com/blog/2016/10/npm_scripts.html
wepy-cli 2.x 初始化了一个项目,然后生成报错 Cannot read property 'addDeps' of undefined, 断点跟踪发现 this.fileDep 是 undefined 文件路径:@wepy/compiler-less/index.js