我收到一个错误,我不知道该怎么做。
Grunt 在我的机器上工作得很好,但在我的服务器上却失败了。他们都是同一个操作系统。而且我在想我的 package.json 可能已经在我的服务器上安装了一个更高版本的东西,它破坏了咕噜声。但是我^
对所有依赖项都使用了,所以它们应该是兼容的。这是咕噜声错误:
Loading "compress.js" tasks...ERROR
>> Error: Cannot find module 'lodash'
Loading "connect.js" tasks...ERROR
>> Error: Cannot find module 'cookie-signature'
Loading "imagemin.js" tasks...ERROR
>> Error: Cannot find module 'js-yaml'
Loading "jasmine.js" tasks...ERROR
>> Error: Cannot find module 'lodash'
Loading "jshint.js" tasks...ERROR
>> Error: Cannot find module 'hooker'
Loading "less.js" tasks...ERROR
>> Error: Cannot find module 'lodash'
/home/jeremy/421_API/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:16208
/**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Loading "requirejs.js" tasks...ERROR
>> SyntaxError: Unexpected token ILLEGAL
Loading "stylus.js" tasks...ERROR
>> Error: Cannot find module 'lodash'
Running "test" (mochaTest) task
1) "before all" hook
0 passing (172ms)
1 failing
1) "before all" hook:
Uncaught Error: Cannot find module 'tough-cookie'
Fatal error: Cannot find module 'tough-cookie'
这是我的 package.json
{
...,
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "~1.12.0",
"cookie-parser": "^1.3.4",
"cors": "^2.5.3",
"express": "~4.12.1",
"express-session": "^1.10.4",
"jade": "^1.9.2",
"method-override": "^2.3.3",
"mongoose": "^4.0.1",
"mongoose-lifecycle": "^1.0.0",
"morgan": "^1.5.2",
"passport": "^0.2.2",
"passport-http": "^0.2.2",
"q": "^1.3.0",
"string": "^3.1.1",
"validator": "^3.37.0"
},
"devDependencies": {
"chai": "^2.3.0",
"execSync": "^1.0.2",
"forever": "^0.14.1",
"grunt": "latest",
"grunt-cli": "^0.1.13",
"grunt-contrib": "^0.11.0",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-coffee": "^0.10.1",
"grunt-contrib-compass": "^0.7.2",
"grunt-contrib-compress": "^0.8.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-csslint": "^0.2.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-handlebars": "^0.8.0",
"grunt-contrib-htmlmin": "^0.2.0",
"grunt-contrib-imagemin": "^0.7.2",
"grunt-contrib-jade": "^0.11.0",
"grunt-contrib-jasmine": "^0.6.5",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-jst": "^0.6.0",
"grunt-contrib-less": "^0.11.4",
"grunt-contrib-nodeunit": "^0.3.3",
"grunt-contrib-qunit": "^0.4.0",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-sass": "^0.7.4",
"grunt-contrib-stylus": "^0.15.1",
"grunt-contrib-symlink": "^0.3.0",
"grunt-contrib-uglify": "^0.4.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-yuidoc": "^0.5.2",
"grunt-mocha": "^0.4.12",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.2.5",
"passport-local": "^1.0.0",
"pm2": "0.12.11",
"supertest": "^1.0.1"
}
}
这是我的 Gruntfile:
// Gruntfile.js
module.exports = function(grunt){
// Load grunt mocha task
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Mocha Test
mochaTest: {
test: {
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/groups.js',
'test/doctors.js',
'test/patients.js',
'test/diet.js',
'test/admin.js']
},
web_enter: { // fill database for website testing
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/web_testing_enter.js']
},
web_remove: { // remove data entered for website testing
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/web_testing_remove.js']
}
}
});
grunt.registerTask('we', ['mochaTest:web_enter']);
grunt.registerTask('wr', ['mochaTest:web_remove']);
grunt.registerTask('default', ['mochaTest:test']);
};