Unable to get NPM to install grunt locally in a way that actually works

grunt-cli: The grunt command line interface (v1.2.0)Fatal error: Unable to find local grunt.If you’re seeing this message, grunt hasn’t been installed locally toyour project. For more information about installing and configuring grunt,please see the Getting Started guide:http://gruntjs.com/getting-started

https://gruntjs.com/getting-started

… definitely says to install grunt-cli globally.

Went ahead and followed https://gruntjs.com/project-scaffolding to create a brand new minimal project:

mlncn@oryx:scratch$ mkd grunttest
mlncn@oryx:grunttest$ grunt-init
grunt-init: command not found
mlncn@oryx:grunttest$ npm install -g grunt-init
npm WARN deprecated coffee-script@1.3.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
/home/mlncn/.nvm/versions/node/v8.4.0/bin/grunt-init -> /home/mlncn/.nvm/versions/node/v8.4.0/lib/node_modules/grunt-init/bin/grunt-init
+ grunt-init@0.3.2
added 53 packages from 63 contributors in 2.663s
mlncn@oryx:grunttest$ grunt-init
Running "init" task

A valid init template name must be specified.

Available templates

(No templates found)

Templates that exist in the /home/mlncn/.grunt-init directory may be run with
"grunt-init TEMPLATE". Templates that exist in another location may be run with
"grunt-init /path/to/TEMPLATE". A template is a directory that must contain, at
the very minimum, a template.js file.

For more information, see http://gruntjs.com/project-scaffolding
mlncn@oryx:grunttest$ l ~/.grunt
ls: cannot access '/home/mlncn/.grunt': No such file or directory
mlncn@oryx:grunttest$ l ~/.grunt-init
ls: cannot access '/home/mlncn/.grunt-init': No such file or directory
mlncn@oryx:grunttest$ git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile
Cloning into '/home/mlncn/.grunt-init/gruntfile'...
remote: Counting objects: 29, done.
remote: Total 29 (delta 0), reused 0 (delta 0), pack-reused 29
Unpacking objects: 100% (29/29), done.
mlncn@oryx:grunttest$ grunt-init gruntfile
Running "init:gruntfile" (init) task
This task will create one or more files in the current directory, based on the
environment and the answers to a few questions. Note that answering "?" to any
question will show question-specific help and answering "none" to most questions
will leave its value blank.

"gruntfile" template notes:
This template tries to guess file and directory paths, but you will most likely
need to edit the generated Gruntfile.js file before running grunt. If you run
grunt after generating the Gruntfile, and it exits with errors, edit the file!

Please answer the following:
[?] Is the DOM involved in ANY way? (Y/n) n
[?] Will files be concatenated or minified? (Y/n) n
[?] Will you have a package.json file? (Y/n) Y
[?] Do you need to make any changes to the above before continuing? (y/N) N

Writing Gruntfile.js...OK
Writing package.json...OK

Initialized from template "gruntfile".

Done, without errors.
mlncn@oryx:grunttest$ l
total 16K
drwxr-xr-x 2 mlncn mlncn 4.0K Sep 10 10:25 ./
drwxr-xr-x 8 mlncn mlncn 4.0K Sep 10 10:22 ../
-rw-r--r-- 1 mlncn mlncn 1.2K Sep 10 10:25 Gruntfile.js
-rw-r--r-- 1 mlncn mlncn  212 Sep 10 10:25 package.json
mlncn@oryx:grunttest$ v Gruntfile.js
mlncn@oryx:grunttest$ grunt
grunt-cli: The grunt command line interface (v1.3.1)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

https://gruntjs.com/getting-started


mlncn@oryx:grunttest$ npm install
npm WARN deprecated coffee-script@1.3.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN grunttest No description
npm WARN grunttest No repository field.
npm WARN grunttest No license field.

up to date in 4.099s
[!] 47 vulnerabilities found [964 packages audited]
    Severity: 28 Low | 10 Moderate | 9 High
    Run `npm audit` for more detail

mlncn@oryx:grunttest$ grunt
grunt-cli: The grunt command line interface (v1.3.1)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

https://gruntjs.com/getting-started

wolcen: now i remember the specific technology problem i wanted to ask you about! Did you figure out grunt on the virtual machine? I thought i’d had it figured out on my local but i re-cloned Agaric patternlibrary and cannot get away from the “Unable to find local grunt” error. Current assumption it’s because i have it installed globally (which grunt

Well at least it’s basically happening to someone else:

https://askubuntu.com/questions/874481/cant-use-grunt-installed-globally

but in my case it’s definitely installed globally and locally, so why won’t it find the local grunt?

Here’s where they just say don’t install grunt globally: https://github.com/gruntjs/grunt-cli/issues/10 “There are a number of issues where we debated all this. While you can undoubtedly get this to work, installing grunt globally is not recommended and is not supported.”

npm uninstall -g grunt did not appear to have any effect

OK apparently it did:

npm uninstall -g grunt
cd patternlibrary
npm install

and grunt and grunt kss work for me in a fresh clone of git@gitlab.com:agaric/patternlibrary.git