无法在mac上的meanjs现有项目中找到本地grunt

时间:2015-09-08 10:48:28

标签: javascript node.js macos

我想在我的mac pc中运行我从朋友处获得的meanjs现有项目,但是当我运行'grunt'命令时,后面的错误就是:

grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

搜索谷歌后,我使用了以下两个命令:

sudo npm install grunt --save-dev

npm install

但是出现以下错误:

Loading "gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

[注意:但是grunt正在为我本地mac上新创建的meanjs项目工作但不是我朋友的这个旧项目]

更新 - 我在这里有package.json文件:

{
  "name": "meanjsapp",
  "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js",
  "version": "0.0.1",
  "engines": {
    "node": "0.10.x",
    "npm": "1.4.x"
  },
  "scripts": {
    "start": "grunt",
    "test": "grunt test",
    "postinstall": "bower install --config.interactive=false"
  },
  "dependencies": {
    "apn": "^1.7.4",
    "async": "~0.9.0",
    "body-parser": "~1.9.0",
    "bower": "~1.3.8",
    "chalk": "~0.5",
    "compression": "~1.2.0",
    "connect-flash": "~0.1.1",
    "connect-mongo": "~0.4.1",
    "consolidate": "~0.10.0",
    "cookie-parser": "~1.3.2",
    "cron": "^1.0.9",
    "express": "~4.10.1",
    "express-session": "~1.9.1",
    "forever": "~0.11.0",
    "glob": "~4.0.5",
    "grunt-cli": "~0.1.13",
    "helmet": "~0.5.0",
    "jsonwebtoken": "^5.0.2",
    "jwt-simple": "^0.3.0",
    "lodash": "~2.4.1",
    "method-override": "~2.3.0",
    "mongoose": "~3.8.8",
    "morgan": "~1.4.1",
    "multer": "^0.1.8",
    "nodemailer": "~1.3.0",
    "passport": "~0.2.0",
    "passport-facebook": "~1.0.2",
    "passport-github": "~0.1.5",
    "passport-google-oauth": "~0.1.5",
    "passport-linkedin": "~0.1.3",
    "passport-local": "~1.0.0",
    "passport-twitter": "~1.0.2",
    "swig": "~1.4.1"
  },
  "devDependencies": {
    "supertest": "~0.14.0",
    "should": "~4.1.0",
    "grunt-env": "~0.4.1",
    "grunt-node-inspector": "~0.1.3",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-csslint": "^0.3.1",
    "grunt-ng-annotate": "~0.4.0",
    "grunt-contrib-uglify": "~0.6.0",
    "grunt-contrib-cssmin": "~0.10.0",
    "grunt-nodemon": "~0.3.0",
    "grunt-concurrent": "~1.0.0",
    "grunt-mocha-test": "~0.12.1",
    "grunt-karma": "~0.9.0",
    "load-grunt-tasks": "~1.0.0",
    "karma": "~0.12.0",
    "karma-jasmine": "~0.2.1",
    "karma-coverage": "~0.2.0",
    "karma-chrome-launcher": "~0.1.2",
    "karma-firefox-launcher": "~0.1.3",
    "karma-phantomjs-launcher": "~0.1.2"
  }
}

有人能帮助我吗?

1 个答案:

答案 0 :(得分:1)

如果与npm一起使用,Node.js项目必须附带package.json文件。 package.json(Babel documentation)文件包含有关项目的所有信息,甚至是依赖项(随--save添加)。

因此,如果您的朋友做的一切正确,您只需运行npm install并应安装所有依赖项。如果没有package.json文件或者没有写入依赖项,则必须手动安装它们。

grunt有很多模块可以工作,其中一个叫做load-grunt-tasks,所以你应该再次运行npm install load-grunt-tasks --save-dev当然这就是你没有文件中的依赖项。