Travis CI:找不到节点模块中的文件



我刚刚配置了Travis CI来运行我的测试用例。这是我.travis.yml文件:

language: node_js
node_js:
  - "0.10"
before_install: npm install -g grunt-cli
install: npm install

当它尝试运行我的测试用例时,它给了我以下错误:

Error loading resource file:///home/travis/build/repo/test/node_modules/mocha/mocha.css    (203). 
Details: Error opening /home/travis/build/repo/test/node_modules/mocha/mocha.css: No such file or directory
Error loading resource file:///home/travis/build/repo/test/node_modules/mocha/mocha.js (203). 
Details: Error opening /home/travis/build/repo/test/node_modules/mocha/mocha.js: No such file or directory
TypeError: 'undefined' is not a function (evaluating 'mocha.setup('bdd')')

因此,它无法在node_modules文件夹中找到mocha.cssmocha.js文件。

我猜它找不到这些文件,因为它们没有上传到 Git。这是因为我在.gitignore文件中指定了node_modules,因为我不想上传所有模块。

解决此问题的常用方法/干净方法是什么?

摆脱这种情况的最简单方法是

$ git add --force node_modules/mocha.css node_modules/mocha.js
$ git commit -m "Add the missing files"
$ git push

"--force"选项允许您添加通过 .gitignore 忽略的文件

相关内容

最新更新