我正在尝试使用Travis进行PR的开源构建。配置非常简单,并且日志似乎显示在运行yarn install
时已安装了适当的模块,并且我正在安装与本地使用的相同版本的yarn。问题是,当我尝试执行package.json脚本对象中定义的脚本时,在Travis中运行时找不到模块。下面是配置和我在构建时收到的错误。
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.7.0
- export PATH="$HOME/.yarn/bin:$PATH"
cache:
yarn: true
directories:
- "node_modules"
env:
- NODE_ENV=production
language: node_js
node_js:
- 8
- 9
- "stable"
install:
- yarn install
script:
- yarn run lint
- yarn test
以上内容在构建日志中产生以下输出:
yarn run v1.7.0
$ ./node_modules/.bin/eslint src/**
/bin/sh: 1: ./node_modules/.bin/eslint: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command "yarn run lint" exited with 1.
0.54s$ yarn run test
yarn run v1.7.0
$ ./node_modules/.bin/jest
/bin/sh: 1: ./node_modules/.bin/jest: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command "yarn run test" exited with 1.
此项目的package.json如下:
"scripts": {
"test": "./node_modules/.bin/jest",
"lint": "./node_modules/.bin/eslint src/**",
"precommit": "lint-staged",
"format": "prettier --trailing-comma es5 --single-quote --write 'src/*/*.js' '!(node_modules)/**/*.js'"
},
答案 0 :(得分:0)
存在相同的问题,并且可以通过在package.json文件中执行以下操作来解决此问题
"scripts": {
"test": "test --passWithNoTests",
}