[英]Can't find globally installed npm packages in Travis ci
.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
在安裝階段,安裝@octokit/rest
軟件包。 但是在第二個部署任務中,當我在./bin/auto_release.js
的第一行中需要它時:
const Octokit = require('@octokit/rest')
Travis CI顯示Error: Cannot find module '@octokit/rest'
。
該項目可在https://github.com/jjyyxx/JSONSchemaSimulator上獲得 。
ci報告可在https://travis-ci.org/jjyyxx/JSONSchemaSimulator/builds/408414549獲得 。
所以我以前沒有和Travis CI合作,但是我使用的是GitLab CI並且實際上也有相同的情況。
問題是,全局包不會被合並到作業的緩存中,因此在install
完成后將被刪除。
對於這種設置,我強烈建議在本地安裝軟件包,而不是全局安裝。
其中一個原因是執行程序可能用於不同的構建作業,如果全局安裝不同的軟件包版本並且相互干擾,那將是非常不幸的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.