不能npm启动本地版本

时间:2014-10-21 10:02:03

标签: javascript node.js

我git拉了一个由一个小开发团队工作的node.js项目。我试图打开一个本地版本(npm start)来玩,并开始对它进行小的修改。

我的问题是,我无法启动它。我尝试了以下方法:

1)只需输入" npm start",其中说明package.json文件有问题(我认为):

npm ERR! this-project@0.0.1 start: `node app.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the this-project@0.0.1 start script.
npm ERR! This is most likely a problem with the this_project package,
npm ERR! not with npm itself.

2)打开mongod(链接到"数据"文件夹" this_project"根文件夹),更改"开始"包JSON中的字段有值"〜/ workspace / this_project / app.js"和npm start:

: command not foundorkspace/this_project/app.js: line 1:
/Users/MichaelYim/workspace/this_project/app.js: line 2: //: is a directory
/Users/MichaelYim/workspace/this_project/app.js: line 3: syntax error near unexpected token `('
'Users/MichaelYim/workspace/this_project/app.js: line 3: `var express = require('express')

npm ERR! Darwin 13.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.10.32
npm ERR! npm  v2.1.2
npm ERR! code ELIFECYCLE
npm ERR! this_project@0.0.1 start: `~/workspace/this_project/app.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the this_project@0.0.1 start script.
npm ERR! This is most likely a problem with the this_project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ~/workspace/this_project/app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls zingly-ugc-management-system
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/MichaelYim/workspace/this_project/npm-debug.log

不知道从哪里开始。有人可以帮助我吗?

app.js的第一部分

// Module dependencies.
var express = require('express')
  , http = require('http')
  , path = require('path')
  , engine = require('ejs-locals')
  , fs = require('fs')
  , nodemailer = require('nodemailer')
  , crypto = require('crypto')
  , request = require('request')
  , moment = require('moment')
  , async = require('async')
  , logs = require('./logs/logs.js')
  , csv = require('csv')
  , GoogleUrl = require('google-url');

var nodeExcel = require('excel-export');
var googleUrl = new GoogleUrl();

var CronJob = require('cron').CronJob;

var app = express();
// Get Configuration Files
var content = JSON.parse(fs.readFileSync(path.join(__dirname, "/package.json")));
var host = content.config.host + ":" + content.config.port;

var transport = nodemailer.createTransport("SMTP", {
  service: content.config.service,
  auth: {
      user: content.config.user,
      pass: content.config.pass
  }
});

的package.json

{
  "name": "this-project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "~/workspace/this-project/app.js"
  },
  "dependencies": {
    "express": "*3.3.4",
    "ejs": "0.8.5",
    "ejs-locals": "1.0.2",
    "mongojs": "0.9.9",
    "moment": "2.5.0",
    "async": "0.2.9",
    "instagram-node-lib" : "0.1.1",
    "nodemailer" : "0.5.14",
    "newrelic" : "1.3.2",
    "crypto" : "0.0.3",
    "csv" : "0.3.6",
    "gm" : "1.14.1",
    "paypal-rest-sdk" : "0.6.4",
    "google-url" : "0.0.2",
    "cron" : "1.0.4"
  },
  "config": {
    "host" : "this.project.me",
    "port" : "8880",
    "hash_prefix" : "this_project",
    "hash_suffix" : "jillM@kk$!@#937",
    "service" : "Gmail",
    "user" : "hello@this.project",
    "pass" : " xxxxxxxxx ",
    "instagram" : {
      "client_id" : "sd87f6asdg97asdf6sad5sdf7",
      "client_secret" : "dfsg6ds5f65dsfg46d4hgf4hd"    
    }
  }
}

1 个答案:

答案 0 :(得分:0)

将app.js文件的第一行设为:

#!/ usr / bin / env node