如何在Ubuntu 16.04 LTS 64位系统上安装/启动Postman本地版v4.10.3?

72

我从https://www.getpostman.com/apps下载了Linux版的Postman,将.tar.gz文件解压到~/bin/postman中,然后尝试执行~/bin/postman/Postman/Postman。不幸的是,它导致了以下错误:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'glob'
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (/home/imilosavljevic/bin/postman/Postman/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/imilosavljevic/bin/postman/Postman/resources/app/node_modules/electron-json-storage/node_modules/rimraf/rimraf.js:7:12)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

在Ubuntu上,是否有其他安装/启动Postman的方法?

13个回答

259

是的,您可以使用以下命令安装Postman:

wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman

你也可以让Postman在Unity启动器中显示:

cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/opt/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
EOL

您只需要使用标准的 Ubuntu 开发安装,无需 node.js 或任何其他依赖。

更多信息请参见我们的博客文章:https://blog.bluematador.com/posts/postman-how-to-install-on-ubuntu-1604/

编辑:更改了 icon.png 的位置。Postman 的最新版本略微更改了其目录结构。


你可以让Ubuntu为你添加到启动器。在你所描述的安装之后,只需执行以下操作:/usr/bin/postman。当Postman启动时,它将出现在启动器中,然后只需右键单击启动器中的图标并选择“锁定到启动器”。 - Joe C
4
对我来说,只需要加上一个“-f”选项就可以了:sudo ln -s /opt/Postman/Postman /usr/bin/postman -f。这条命令的作用是创建一个指向/opt/Postman/Postman目录的符号链接,并将其命名为/usr/bin/postman。使用“-f”选项会强制覆盖任何已存在的同名文件。 - Maykonn
根据 https://unix.stackexchange.com/a/8658/30962,最好将非 Aptitude 管理的软件包安装在 /usr/local/bin 而不是 /usr/bin 下。 - Juampy NR
3
在安装 sudo apt-get install libgconf-2-4 后,Ubuntu 18.04 上运行得非常好。 - wSkc
1
我按照上述步骤操作,但在我的启动器中没有找到Postman。我通过在终端中输入命令“postman”来启动Postman。我使用Ubuntu 14.04。 - anhduc.bkhn
显示剩余2条评论

26

编辑:

如果您已经安装了snap或想要安装它,只需执行以下操作:

$ sudo snap install postman

如果您没有它,请安装如下:

$ sudo apt update
$ sudo apt install snapd

另一种方法是创建一个脚本:

首先创建这个脚本:

创建一个名为install-postman.sh的文件,在其中添加以下内容:

#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz

echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
    sudo rm -rf /opt/Postman
fi
sudo mv Postman /opt/Postman

echo "Creating symbolic link..."
if [ -L "/usr/bin/postman" ];then
    sudo rm -f /usr/bin/postman
fi
sudo ln -s /opt/Postman/Postman /usr/bin/postman

echo "Installation completed successfully."
echo "You can use Postman!"

在终端中运行以下命令:

$ sh install-postman.sh

接下来创建桌面启动器:

Postman.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/opt/Postman/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;

如果您想要,将此文件放在您的桌面上(不要忘记授予执行权限)。双击即可!

永远感谢Aviskase(GitHub账户名)。

来源 -> https://gist.github.com/aviskase/e642248c35e400b56e2489430952369f#file-postman-desktop


谢谢。尽管我尝试通过下载并运行“ln”命令以及尝试生成“.desktop”文件条目来手动安装它,但最终对我有效的唯一方法是使用snap命令(Ubuntu 16.04)。 - DarkCygnus

8
sudo snap install postman

这个单一命令对我非常有效。

6
这对我来说很有效,在Ubuntu 18.04上,使用发布于2019年5月20日的Postman v7.1.1
下载Postman的最新版本。 你下载的文件很可能在下载文件夹中。
# Postman-linux-x64-7.1.1.tar.gz is my downloaded file

cd /home/YOUR_USERNAME/Downloads/
tar -xzf Postman-linux-x64-7.1.1.tar.gz Postman/
sudo mv Postman /usr/share/postman
sudo ln -s /usr/share/postman/Postman /usr/bin/postman

如果您遇到这样的错误,
/usr/share/postman/Postman: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory

请安装libgconf-2-4
sudo apt install libgconf-2-4

只需在终端中键入postman并按回车键即可运行最新版本的Postman。现在,我们需要为您的启动器创建一个Unity桌面文件。要创建postman.desktop文件,请运行以下命令。

sudo nano ~/.local/share/applications/postman.desktop

接着将以下内容粘贴到 postman.desktop 文件中。

[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/usr/share/postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;

现在你可以在Unity启动器中看到“Postman”图标。如果你遗漏了任何点,请通过视频查看或在下方评论。

Postman 7.1.1


4

不要忘记添加sudo,否则你将会得到postman.tar.gz: Permission denied 的错误提示。如果你遇到类似 "failed to create symbolic link /usr/bin/postman: File exists" 的错误提示,请先删除 postman 再进行操作。以下是完整代码:

sudo wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo rm postman.tar.gz

sudo unlink /usr/bin/postman
sudo ln -s /opt/Postman/Postman /usr/bin/postman

然后只需在终端中运行Postman。

3

是的,我找到了一款非常棒的简单bash脚本,可以让您直接从终端更新Postman Linux应用程序,名为postman-updater-linux

只需使用NPM安装即可:

npm install -g postman-updater-linux

然后检查更新:

sudo postman-updater check

然后安装:

sudo postman-updater install

或更新:

sudo postman-updater update

所有这三个命令都可以通过在命令末尾添加-l /your/custom/path来使用自定义位置。该路径可以是任何有效的文件路径。

2

open terminal and type command

sudo snap install postman

按下回车键,如果要求输入密码,请输入并继续进行,它将安装Postman。

如果上述解决方案对您不起作用,则应先安装Snap才能安装它。


注:Original Answer翻译成“最初的回答”
sudo apt update
sudo apt install snapd

当成功安装Snap后,您可以使用其包并按照我的解决方案使用Postman。

注:Snap是一种用于软件打包、分发和管理的技术。


1
不要忘记。
chmod ~/.local/share/applications/postman.desktop +x

否则它不会显示在Unity启动器中。

1
要做相同的事情,我在终端中执行了以下操作-
$ wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
$ sudo tar -xzf postman.tar.gz -C /opt
$ rm postman.tar.gz
$ sudo ln -s /opt/Postman/Postman /usr/bin/postman
  1. 现在打开文件系统,移动到 /usr/bin/ 并搜索 "Postman"
  2. 会有一个名为 'Postman' 的 sh 文件
  3. 双击它打开 Postman。
  4. 右键单击它的图标将锁定图标以供进一步使用。

希望这也能帮助其他人。


1

我遇到了一个问题,无法在浏览器中使用“在Postman中运行”链接,直到我将以下内容添加到 .desktop 文件中。

MimeType=application/postman;x-scheme-handler/postman;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接