2

centos deploy nexus3

Environment: jdk1.8 , nexus3

Upload and extract nexus3, install jdk and configure environment variables

 vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

Execute the effective environment variable command source profile

nexus3 start:

Execute to /usr/local/packages/nexus-3.13.0-01/bin in this directory

Path: /usr/local/packages/nexus-3.13.0-01/
Execution startup: under the path /bin
./nexus run & //有打印日志启动
./nexus start //无打印日志启动
./nexus stop or kill -9 进程id //命令失效杀进程停止

Nexus deploys npm private server

1. blobStores create repository: npm-store

2. Create repositories : npm-hosted repository and copy the npm source address

3. Local configuration associated npm source address
npm config set registry 远程npm仓库地址
npm login

4. Publish the package to the remote repository
Execute npm publish to the project directory containing package.json (private: false) (Unable to process dependencies, download package is incomplete.)
npm supports uploading to private libraries by directly publishing tgz compressed packages.
Download node-tgz-downloader to download the dependent tgz file; the script will download the associated dependency package through the packagelock.json locked dependency package version)

Install globally:
npm install node-tgz-downloader -g

After generating the npm install node_modules folder, go to the project root directory to execute the command download-tgz package-lock package-lock.json network and overseas server reasons may fail and need to download more 0kb compressed packages. Do it a few times.

Publish the tgz package to a private repository:

shell script (integrate tgz package into one directory)

 find . -name '*.tgz' -exec cp -f {} ../tgz \;

This command will copy the .tgz compressed package in multiple directories to the tgz directory.

New sh script

 #!/bin/bash

PACKAGE_PATH=./tgz
REPOSITORY=http://xxxxx:8081/repository/npm-hosted/

# npm login --registry=$REPOSITORY

for file in $PACKAGE_PATH/*.tgz; do
 npm publish $file
done

The script will release the package in sequence in a synchronized manner. If you encounter 403, you can consider the permission problem, and it is best to use the administrator account to release.

Node-sass installation failure handling:

When pulling the node-sass package, node-sass will also pull the xx_binding.node a binary node file from git even though the intranet already has all the npm packages. After reading the source code, I found this file Whether to identify the current sass version and the computer system and computer 32-bit or 64-bit to download the binary file, the getBinaryName method returns the file name

 binaryName = [
      platform, '-',
      process.arch, '-',
      process.versions.modules
    ].join('');

    return [binaryName, 'binding.node'].join('_');

The file name (darwin-x64-83) can be viewed by manual cmd input,

 node -p "[process.platform,process.arch,process.versions.modules].join('-')"

darwin-x64-83_binding.node is the final full filename.

View the current installation package tgz package npm view http-server dist.tarball

Then check the node-sass version in package.json, and download the corresponding file through https://registry.npmmirror.com/binary.html?path=node-sass/version number/filename.

Create a raw hosted repository (raw-hosted) and a raw group repository (raw-public) on the nexus and set read permissions. Refer to the npm source download address to create a new node-sass/v4.14.1/ directory and upload the binary file. Full path ( http://ip:port/repository/raw-public/node-sass/v4.14.1/win32-x64-83_binding.node ).

View a single package download address

npm view packname

First npm install using private server source

Point to the private server source and binary file source directory respectively. The binary file site (sass_binary_site) only needs to point to the split directory in front of the version. When downloading, it will automatically download the corresponding file according to the node-sass version.

npm config set registry http://ip:port/repository/npm-public/

npm config set sass_binary_site http://ip:port/repository/raw-public/node-sass

npm install

If the installation error is reported above, you can check the warehouse permission problem set by nexus. When the installation is successful and the error is reported, try to clear the npm cache npm cache clean -f

Supplement npm package download method 2 (solution package download package 0kb or failure):

Create a new directory at the same level of the package write.txt and modify the package node-tgz-downloader code is as follows:

 var arr = [];
const promises = tarballs.map(({ url, directory }, i, arr) => {
    const position = `${i + 1}/${arr.length}`;
    logger(['downloading'.cyan, position], url);
        arr.push(url)
        if((tarballs.length - 1) == i){
            fs.writeFile('./xieru.txt',JSON.stringify(arr),function(err){
              // 读取失败 err的值也是为空  null转换为布尔值还是false
              if (err) {
                return console.log(err+'写入失败的');
              }
              console.log('写入成功');
            })
            
        }
    return _downloadFileWithRetry(url, join(baseDirectory, directory), position, 10);
  });

New directory at the same level index.html

 <div id="app"></div>

<script type="text/javascript" src="./write.txt"></script>
<script type="text/javascript">
fetch('./write.txt')
 .then(function(response) {
   return response.json();
 })
 .then(function(myJson) {
   let app = document.querySelector('#app');
myJson.map((item,i)=>{
    let el = document.createElement('a');
    el.innerText = item; 
    el.href = item;
    app.appendChild(el).appendChild(document.createElement('p'))
})
 });
</script>

Run html to select all copy and download Thunder and paste to download.

Reference related materials:
https://blog.csdn.net/lihongtai/article/details/84611418
https://blog.csdn.net/yougoule/article/details/56843562
https://segmentfault.com/a/1190000040027813


a2774206
1.8k 声望26 粉丝

You can't forget your role at all times