特拉维斯给出了错误,但在电脑上编译

时间:2016-11-16 16:13:50

标签: node.js travis-ci

我正在使用Node.JS创建一个Web服务器,并使用Travis-Ci检查我的代码。我得到的问题是当我提交我的代码时,Travis在下面给出了错误,但代码在我的电脑上编译没有错误:

  

./backend/server.js:1:语法错误: (意外

在这里,您可以找到我的.travis.yml文件:

install:
  - npm install
  - npm install -g bower
  - bower install bootstrap
  - bower install socket.io
language: node_js
node_js:
  - "6.9"
before_script: 
  - chmod 0777 ./backend/server.js
cache:
  directories:
    - node_modules
    - bower_components

package.json

{
  "name": "watchfriends",
  "version": "0.0.0",
  "description": "Front-end and back-end project watchfriends",
  "main": "gulpfile.js",
  "scripts": {
    "test": "./backend/server.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/WatchFriends/Backend.git"
  },
  "author": "Hein P., Jasper D., Michiel V., Michiel Z.",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/WatchFriends/Backend/issues"
  },
  "homepage": "https://github.com/WatchFriends/Backend#readme",
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-clean-css": "^2.0.13",
    "gulp-concat": "^2.6.1",
    "gulp-csslint": "^1.0.0",
    "gulp-htmlhint": "^0.3.1",
    "gulp-jshint": "^2.0.4",
    "gulp-notify": "^2.2.0",
    "gulp-sass": "^2.3.2",
    "gulp-sourcemaps": "^2.2.0",
    "gulp-uglify": "^2.0.0",
    "jshint-stylish": "^2.2.1"
  },
  "dependencies": {
    "socket.io": "^1.5.1"
  }
}

this gist上,您可以找到我的代码,包括日志。

我有什么问题吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

Travis在测试代码时运行npm test

如果您在" package.json"内部进行检查然后,您可以看到test脚本设置为运行./backend/server.js。您需要使用节点运行节点文件。

将其更改为node ./backend/server.js,希望能够正常运作。