我想知道是否有离线安装的方法?我的意思是,是否有办法将这些文件带到USB驱动器或其他设备中,然后进行安装?
这可能吗?
谢谢大家 :)
是的,您可以使用Yarn在没有互联网连接的情况下安装软件包。
例如,全局安装ionic
和cordova
:
On the internet machine (configure local cache location):
yarn config set yarn-offline-mirror ~/yarn-offline-mirror/
On the offline machine (configure local cache location):
yarn config set yarn-offline-mirror ~/yarn-offline-mirror/
On the offline machine, Find out where is the global installation location:
yarn global bin
(Or set it with yarn config set prefix <file_path>
)
On the offline machine, add it to your path. E.g.:
echo 'export PATH=$PATH:'"$(yarn global bin)" >> ~/.bashrc
source ~/.bashrc # reload
On the internet machine, download ionic
's and cordova
's dependencies:
mkdir new-cli-ionic-cordova/
cd new-cli-ionic-cordova/
yarn add ionic cordova
Then copy new-cli-ionic-cordova/yarn.lock
and ~/yarn-offline-mirror/
to the offline machine. (rm -rf new-cli-ionic-cordova/
is ok now.)
On the offline machine, install ionic
and cordova
from local cache:
cp /path/to/imported/yarn.lock .
cp -n /path/to/imported/yarn-offline-mirror/* ~/yarn-offline-mirror/
yarn global add --offline ionic cordova
rm -f ./yarn.lock
您也可以使用类似的过程将软件包安装为单个项目的依赖项。有关更多信息,请参阅我的帖子:https://assafmo.github.io/2018/04/11/yarn-offline.html
首先,我建议您尝试让npm-config在代理服务器上正常工作。请与您的IT部门联系,了解如何连接到https://www.npmjs.com/package/注册表。如果您还没有找到它们,可能以下链接会有所帮助:
如果这些方法都无法解决问题,那么您可以考虑设置本地软件包注册表。也许Sinopia可以帮助您。但是……
还有其他想法吗?
您可以通过代理使npm正常工作以解决问题。为此,设置HTTP_PROXY和HTTPS_PROXY环境变量非常重要。
对于HTTP_PROXY,您可以使用
npm config set proxy http://proxy_host:port
对于 HTTPS_PROXY,您可以尝试使用这个
npm config set https-proxy http://proxy.company.com:8080
步骤1:下载Node.js:https://nodejs.org/en/download/
步骤2:tar xvf node-v16.17.0-linux-x64.tar.xz
步骤3:添加到环境变量中:
vim /etc/profile.d/nodejs.sh:
#!/bin/sh
export PATH=/YOUR-PATH-TO/node-v12.16.2-linux-s390x/bin:$PATH
or
vim ~/.bash_profile:
export PATH=/YOUR-PATH-TO/node-v12.16.2-linux-s390x/bin:$PATH
方法1:
on machine A which has internet access:
npm install all the packages needed
upload the node_modules/* to /YOUR-PATH-TO/node-v12.16.2-linux-s390x/lib/node_modules/
方法二:
on machine A which has internet access:
>npm install -g npm-bundle
>npm install -g eslint
>npm-bundle eslint
eslint-7.8.1.tgz
on the target machine which has no internet access:
>npm install -g ./eslint-7.8.1.tgz