NPM 和 yarn

win 10
表示每次一碰到 npm 和 yarn 的时候都好多问题,之前第一个教程装的homesead,到了npm和yarn那里执行就很多warn和error,当时觉得里面用的比较多的是编译css,为了顺利推进,手动改一下css就算了。
上周末刚重新装了一边homestead,今天到这里的时候依然n多warn和error,不知道后面能否顺利完成,:disappointed_relieved:

vagrant@homestead:~/code/wepy-weui-demo$ yarn
yarn install v1.7.0
info No lockfile found.
[1/4] Resolving packages...
warning babel-preset-es2015@6.24.1: ????  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
warning wepy-plugin-imagemin > imagemin-mozjpeg > mozjpeg > bin-build > download > gulp-decompress > gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > eslint-config-standard@7.1.0" has incorrect peer dependency "eslint-plugin-promise@>=3.3.0".
warning " > wepy-compiler-less@1.3.14" has unmet peer dependency "less@^3.8.1".
error An unexpected error occurred: "EPROTO: protocol error, symlink '../acorn/bin/acorn' -> '/home/vagrant/code/wepy-weui-demo/node_modules/acorn-jsx/node_modules/.bin/acorn'".
info If you think this is a bug, please open a bug report with the information provided in "/home/vagrant/code/wepy-weui-demo/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
vagrant@homestead:~/code/wepy-weui-demo$ wepy build
{ Error: Cannot find module 'less'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/vagrant/code/wepy-weui-demo/node_modules/wepy-compiler-less/lib/index.js:20:13)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.load (/usr/local/share/.config/yarn/global/node_modules/wepy-cli/lib/loader.js:113:17)
    at Object.loadCompiler (/usr/local/share/.config/yarn/global/node_modules/wepy-cli/lib/loader.js:69:29)
    at Object.checkCompiler (/usr/local/share/.config/yarn/global/node_modules/wepy-cli/lib/compile.js:178:35)
    at Object.init (/usr/local/share/.config/yarn/global/node_modules/wepy-cli/lib/compile.js:221:19) code: 'MODULE_NOT_FOUND' }
[WARNING] 找不到编译器:wepy-compiler-less。
[10:46:20] [信息] 检测到有效NPM包资源,正在尝试安装,请稍等。
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN rollback Rolling back acorn-jsx@3.0.1 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/code/wepy-weui-demo/node_modules/acorn-jsx/package.json.3911671089'
vagrant@homestead:~/code/wepy-weui-demo$ npm install
npm WARN deprecated babel-preset-es2015@6.24.1: ?  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN rollback Rolling back babel-runtime@6.26.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/code/wepy-weui-demo/node_modules/babel-generator/node_modules/babel-runtime/package.json.2144866086'
npm WARN rollback Rolling back babel-runtime@6.26.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/code/wepy-weui-demo/node_modules/babel-helper-bindify-
vagrant@homestead:~/code/wepy-weui-demo$ npm install less --save
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN rollback Rolling back asap@2.0.6 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/code/wepy-weui-demo/node_modules/asap/package.json.441995234'
npm WARN rollback Rolling back assert-plus@1.0.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/code/wepy-weui-demo/node_modules/assert-plus/package.json.1634628732'
npm WARN rollback Rolling back asynckit@0.4.0 failed (this is probably harmless): ETXTBSY: text f

社区里面找了一些方法,没能解决问题。

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 6
liyu001989

yarn 更新到 1.12.3 然后删掉 node_modules 重新安装试试

5年前 评论

@liyu001989 当前版本就是 v1.12.3 哦

5年前 评论
liyu001989

file

啊?

5年前 评论

@liyu001989 问题解决了
一开始执行 wepy build 的时候提示 cannot find module 'less',找了很久没找到解决方法,
后来在 问答:[WARNING] 找不到编译器:wepy-compiler-Less。 中有一个朋友提供了 yarn add less --no-bin-links 的命令,执行之后成功安装好了less模块 (时间有点久),再执行 wepy build 就成功编译了。
之前遇到问题的时候自己尝试过 yarn add less ,没有加 --no-bin-links,无效。
表示没摸透的情况下使用一样工具就用的好懵逼

5年前 评论

关于 npm 和 yarn 的执行错误,大多出现为两处,
1.软连接创建失败,解决方法:在命令后面添加 --no-bin-links,可以解决
2.执行 npm run watch-poll 时报错 cross-env not found ,https://blog.csdn.net/qq_37910492/article/... 得到解决。
3.一个性能的小问题,虚拟机中运行 npm run watch-poll 物理机出现cpu过高, https://blog.csdn.net/qq_37910492/article/... 得到解决
暂时来说已经没有问题了。

5年前 评论
ruodee

具体细节去论坛查,我说说我的解决思路:
1.安装的nodejs升级为最新稳定版本,npm-cli升级为适配版本。
2.yarn升级为最新版本。
3.npm、yarn的registry设置为国内镜像地址。
然后就没问题了。

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!