梦相随1006

版权归 梦相随1006 所有,未经 https://www.cnblogs.com/xin1006 作者许可,严禁转载

导航

导入VUE前端工程npm install yarn install 常见错误 及其互转

1. 我这里使用了nrm命令来切换npm的实际镜像

2.切换为淘宝镜像 nrm use taobao

3.下载依赖包 npm install

结果一直卡在sill install loadAllDepsIntoIdealTree,如果有耐心就可以等到错误出来,

4. 查看日志文件 C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-07-07T00_42_01_336Z-debug.log

发现里面有的代理地址有问题 

 https://registry.npm.taobao.org/@XXX failed, reason: connect ETIMEDOUT 93.184.216.34:8080

5. 该问题的处理方式是 去除代理

6,再重新运行npm install,基本都能下载,我们又遇到了node-sass下载不下来的问题.

7. 解决node-sass问题关键就是改该文件下载的地址npm config set sass-binary-site https://npm.taobao.org/mirrors/node-sass

OK

 

 如果遇到 项目运行npm install出现,如下错误:

Unexpected end of JSON input while parsing near ‘…4Dfnni2pHBfCQQ1hgyNg3’

解决方法:

运行 npm cache clean --force , 后再运行 npm install.

-----------------------------------------------------------------------------2021-11-11 start -----------------------------------------------------------

公司的大脑项目前端应用需要依次执行以下命令才能完成打包

npm install -g yarn

yarn intall

(项目中有报错,有node-gyp 它是使用到了python27,需要手动安装以下Python27版本的在计算机上)

yarn run dev

--------------------------------------------------------------------------2021-11-11 end -----------------------------------------------------

-----------------------------------------------------------------------------2021-12-18 start -------------------------------------------------

新公司的电网项目前端应用需要依次执行以下命令才能完成打包

1. 将SVN上的npm离线包 拷贝到 C:\Users\XXX\AppData\Roaming\npm 和  C:\Users\XXX\AppData\Roaming\npm-cache

2. 将前端包导入到IDEA(或VSCode)编辑器中

3. 如果node.js的版本不同,建议还是先在项目的控制台上执行命令   npm install

4. 在终端上输入命令  npm run dev 开启服务,或 npm run build 打包

--------------------------------------------------------------------------2021-11-11 end ---------------------------------------------------

 

不过在运行 npm run dev 时候,还是报了问题...

原因就是我们公司这个项目是 yarn.lock锁定的版本.  所以我需要改成使用 yarn来安装依赖.

注意: yarn也我遇到了个坑,我用yarn1.20及其以上版本运行 yarn install 时候一直报问题,,,后来改成低版本的 yarn1.9.2 就把依赖装成功了, 项目也启动起来了.

 

补充知识:  yarn.lock文件与package-lock.json 互转

 

npm install -g synp

yarn.lock => package-lock.json

yarn # be sure the node_modules folder dir and is updated
synp --source-file /path/to/yarn.lock
# will create /path/to/package-lock.json

package-lock.json => yarn.lock

npm install # be sure the node_modules dir exists and is updated
synp --source-file /path/to/package-lock.json
# will create /path/to/yarn.lock

转换生成package-lock.json后,我删除node_models文件夹,然后用npm install 就能把依赖包安装成功,npm run dev也没有问题.

我的软件版本

posted on 2020-07-07 13:01  梦相随1006  阅读(3073)  评论(0编辑  收藏  举报