npm install 在私有包上输出 404 错误,但在 vagrant 中工作

Joã*_*des 5 vagrant gitlab homestead npm-install

阅读了 SO 中的几个线程,但还没有找到确切的某种类型的问题。我在尝试安装我公司(托管在 GitLab 上)的私有包时遇到问题。最奇怪的是,我已经为同一个仓库做了它,但在 vagrant 中。在 vagrant 上,收到以下错误后npm install

\n
ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/@company-name%2foauth20-provider - Not found\nnpm ERR! 404\nnpm ERR! 404  \'@company-name/oauth20-provider@0.8.0\' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 It was specified as a dependency of \'project-srv\'\nnpm ERR! 404\nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git url.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     C:\\Users\\Jo\xc3\xa3o~1\\AppData\\Roaming\\npm-cache\\_logs\\2022-02-06T14_38_17_991Z-debug.log\n
Run Code Online (Sandbox Code Playgroud)\n

我通过以下步骤解决了这个问题:

\n

1 -在 GitLab(范围 API)上生成新的个人访问令牌:https://gitlab.com/-/profile/personal_access_tokens

\n

2 -运行命令:

\n
npm config set @company-name:registry https://gitlab.com/api/v4/projects/project-id/packages/npm/\nnpm config set -- \'//gitlab.com/api/v4/projects/project-id/packages/npm/:_authToken\' "<my-personal-access-token>"\n
Run Code Online (Sandbox Code Playgroud)\n

当我尝试在npm installvagrant 之外运行(在同一文件夹或存储库的另一个克隆中)时,它仍然给出上面的 404 错误。问题是,我确信我尝试过的步骤是有效的,因为它们在 vagrant 中工作。尝试npm install在 vagrant 之外做些什么可能会改变什么?我相信这可能与操作系统有关,因为我使用的是 Laravel Homestead vagrant box(即 Ubuntu 20.04),并且我在 Windows 10 计算机上运行它。

\n