Tuesday 30 May 2017

grunt-cli can't find dependencies

I have the following package.json

{
"name": "***",
"version": "0.1.0",
"devDependencies": {
    "grunt": "^0.4.4",
    "grunt-browser-sync": "^0.8.2",
    "grunt-contrib-clean": "^0.5.0",
    "grunt-contrib-concat": "^0.4.0",
    "grunt-contrib-copy": "^0.5.0",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-uglify": "^0.4.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-karma": "^0.8.3",
    "grunt-sass": ">=0.12.1",
    "grunt-typescript": "^0.3.0",
    "protobufjs": "^2.0.5",
    "normalize.css": "^3.0.1"
},
"scripts": {
}

}

I installed grunt-cli globally with no errors. All dependencies from package.json also installed with no errors.

When i try to run grunt to see if it works, i get error "Cannot find module" Module name is one of grunt's dependencies. For example:

module.js:471
throw err;

Error: Cannot find module 'kind-of'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/to-object-path/index.js:10:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

I tried to install some of dependencies manually, but error persists(only module name changes). I don't think that installing all dependencies manually is the option, perhaps problem is somewhere else.

I tried to run sudo grunt - and.. it works! :)

I tried to run sudo -E grunt - also works :) (my idea was that problem is with environment variables for my user)

So, to sum up: how to make grunt work when executed by usual user, not root?



via valentin.mu

No comments:

Post a Comment