[英]Can't find globally installed npm packages in Travis ci
The .travis.yml
file is: .travis.yml
文件是:
language: node_js
node_js:
- node
env:
global:
- secure: "[redacted]"
before_install:
- node ./bin/version_check.js
install:
- npm i
- npm i -g codecov
- npm i -g @octokit/rest
script:
- npm run lint
- npm run build
- npm run ci
deploy:
- skip_cleanup: true
provider: npm
email: obfishstudio@gmail.com
api_key:
secure: "[redacted]"
on:
repo: jjyyxx/JSONSchemaSimulator
branch: master
- skip_cleanup: true
provider: script
script: node ./bin/auto_release.js
on:
repo: jjyyxx/JSONSchemaSimulator
branch: master
On the install stage, @octokit/rest
package is installed. 在安装阶段,安装
@octokit/rest
软件包。 But in the second deploy task, when I required it in the first line of ./bin/auto_release.js
: 但是在第二个部署任务中,当我在
./bin/auto_release.js
的第一行中需要它时:
const Octokit = require('@octokit/rest')
Travis CI showed that Error: Cannot find module '@octokit/rest'
. Travis CI显示
Error: Cannot find module '@octokit/rest'
。
The project is available at https://github.com/jjyyxx/JSONSchemaSimulator . 该项目可在https://github.com/jjyyxx/JSONSchemaSimulator上获得 。
The ci report is available at https://travis-ci.org/jjyyxx/JSONSchemaSimulator/builds/408414549 . ci报告可在https://travis-ci.org/jjyyxx/JSONSchemaSimulator/builds/408414549获得 。
So I haven't worked with Travis CI before, but I'm using GitLab CI and actually had the same situation. 所以我以前没有和Travis CI合作,但是我使用的是GitLab CI并且实际上也有相同的情况。
The problem is, that the global packages will not be incorporated into the cache for the jobs, and therefore will be removed after install
has finished. 问题是,全局包不会被合并到作业的缓存中,因此在
install
完成后将被删除。
For this kind of setup, I highly recommend installing the packages locally, not globally. 对于这种设置,我强烈建议在本地安装软件包,而不是全局安装。
One of the reasons for this is that an executor might be used for different build jobs, where it would be very unfortunate if different package versions are installed globally and interfere with each other. 其中一个原因是执行程序可能用于不同的构建作业,如果全局安装不同的软件包版本并且相互干扰,那将是非常不幸的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.