nodejs打包问题解决实例

node命令集合

npm set registry https://registry.npm.taobao.org/

cnpm set registry https://registry.npm.taobao.org/

npm config set registry https://registry.npmjs.org/

npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/

npm get registry

 

//npm安装包的提示操作目录权限不足

npm config set unsafe-perm=true

npm config set python /usr/bin/python2

//限制npm网络请求的并发度

npm set maxsockets 5

npm install

npm install中断后可以多次继续执行npm install 直到把所有的依赖包装完

npm install cnpm

npm install --unsafe-perm node-sass

        //清空缓存文件

        npm cache clean --force

//跳过自签名证书验证

NODE_TLS_REJECT_UNAUTHORIZED=0 cnpm install

DEBUG=* cnpm run build:prod

 

nvm ls

nvm install v16.15.1

nvm use v16.15.1

nvm alias default v16.15.1

 

npm config set unsafe-perm=true

npm install

npm run build:prod

node-sass安装

npm config set python /usr/bin/python2

npm install --unsafe-perm node-sass

 

静默强制覆盖 不需要输入y确认

\cp -f -r * /var/lib/jenkins/workspace/test-55-h5/node_modules/

解决示例

        

        

         

 npm和cnpm

          npm  install

          npm install 执行到这里的时候基本上可以安装依赖包成功

           

            npm install 成功的状态信息

             

           npm build状态信息

             

         cnpm 安装

            cnpm 虽然可以安装node_modules成功,但是包的版本容易发生冲突 。在build的时候经常会出现一些异常

            npm install 一旦安装成功 基本上可以build成功

   npm socket超时

            npm ERR! network read ETIMEDOUT

           

          出现这个问题一般都是当前网络不太好导致下载依赖包超时,降低npm网络的请求并发量在进行npm install

          npm set maxsockets 5 && npm install

           

          

 jenkins项目缓存问题

            rm -fr 80-nginx-prod@tmp  &&  cd 80-nginx-prod  && rm -fr *

            

            

           

          

posted @ 2024-03-16 11:22  不懂123  阅读(10)  评论(0编辑  收藏  举报