Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run grunt command because of error: cannot find module 'liftoff'

I'm starting a simple HTML project with Bootstrap 4 where I want to use compiled sass. To do this I've installed grunt using node.js and later steps described on https://gruntjs.com/getting-started.

When I'm typing grunt command the result is:

Error: Cannot find module 'liftoff' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15) at Function.Module._load (internal/modules/cjs/loader.js:529:25) at Module.require (internal/modules/cjs/loader.js:658:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (C:\Bitnami\nodejs-7.3.0-0\nodejs\node_modules\grunt-cli\bin\grunt:7:15) at Module._compile (internal/modules/cjs/loader.js:722:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10) at Module.load (internal/modules/cjs/loader.js:620:32) at tryModuleLoad (internal/modules/cjs/loader.js:560:12) at Function.Module._load (internal/modules/cjs/loader.js:552:3)

I've tried to figure out this by installing npm install liftoff. This module was installed properly but still I cannot run grunt.

My gruntfile.js looks like this:

module.exports = function(grunt) {
'use strict';

grunt.initConfig({
    watch: {
        sass: {
            files: ['sass/**', 'Gruntfile.js'],
            tasks: ['sass'],
        },
        uglify: {
            files: ['js/index.js', 'Gruntfile.js'],
            tasks: ['uglify'],
        }
    },
    sass: {
        production: {
            options: {
                compress: true,
                strictUnits: true
            },
            files: {
                'styles.css': 'styles/styles.sass',
            }
        }
    },
    uglify: {
        options: {
            beautify: true,
            mangle: false,
            compress: {
                drop_console: true
            }
        },
        build: {
            files: {
                'index.min.js': ['js/index.js'],
            }
        }
    }
});

grunt.registerTask('default', ['css', 'js']);
grunt.registerTask('css', ['sass']);
grunt.registerTask('js', ['uglify']);

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
};

What am I missing? I'm quite new to npm grunt so maybe solution is simple but I didn't find answer strictly related to 'liftoff' module. I'm trying to do this on Windows 7. Thanks for any help.

like image 636
nymphais Avatar asked Nov 21 '18 09:11

nymphais


1 Answers

I also hit this on a clean install on Ubuntu 20.04. I eventually hunted down a recipe at https://ask.openrouteservice.org/t/cannot-find-module-liftoff/1718/5 that seems to fix the problem (not sure why) using nvm to install node v14.16.1, then install grunt-cli globally and grunt locally:

nvm install v14.16.1
npm install -g grunt-cli
npm install grunt
like image 56
sfnd Avatar answered Sep 22 '22 08:09

sfnd