question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm test currently doesn't work without globally installing grunt-cli

See original GitHub issue

npm test currently doesn’t work in a freshly cloned + npm installed repo because grunt-cli isn’t in devDependencies

commands in the scripts field of package.json e.g. {"scripts": {"start": "ghost"}} will resolve to the local module scope instead of requiring global installation. This means that working versions of modules can get bundled with applications.

for example, in the above example when npm start runs it will look for a module in the local available require scope that provides a ghost bin, and will use that. if it can’t find a local module it will try the $PATH.

if I had two applications on my computer that both depend on ghost, but one depends on ghost v1 and another on ghost v2 (for example), it would suck if I had to npm install -g ghost@1.0.0 every time I went into the first project and then npm install -g ghost@2.0.0 in the other one. using npm scripts solves this problem. (I hope my explanation makes sense)

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
shamacommented, Feb 16, 2014

It works for me on OSX 10.9.1 and node.js v0.10.22, ruby-2.0.0-p247.

I did a fresh rm -rf Ghost && git clone git://github.com/TryGhost/Ghost && cd Ghost, npm i (which ran bundle install && grunt init from the npm install hook). Then npm start

I then removed my globally installed grunt-cli with npm uninstall -g grunt-cli and repeated the above.

- npm install -g grunt-cli in the before_install of the .travis.yml is no longer needed. Also in the contributing guidelines, 1. Run npm install -g grunt-cli is no longer needed. As well as grunt init as that will be ran automatically when the user does npm install.

The message: >> Local Npm module "grunt-cli" not found. Is it installed? comes from trying to load grunt-cli as a grunt task. Simply change the matchdep line in the Gruntfile.js to require('matchdep').filterDev(['grunt-*', '!grunt-cli']).forEach(grunt.loadNpmTasks); to avoid loading grunt-cli as a grunt task.

Happy to send a PR for any of the above if that is easier. Thanks!

0reactions
hswolffcommented, Feb 17, 2014

Case 1) Installing from npm, which runs npm install automatically.

As you noted @ErisDS there is no need to run any npm script in this scenario as the built scripts will be included in the npm package.

Adding "prepublish": "grunt && grunt prod" to the package.json file will rightly ensure the built files are always present.

Case 2) Cloning from git and running npm install

Small nit, but I’d argue we should move development specific commands back to the Gruntfile.js as that is where all development tasks currently reside. Adding them to the package.json file adds another location that will require maintenance, which isn’t necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node package ( Grunt ) installed but not available
There is one more way to run grunt on windows, without adding anything globally. This is a case when you don't have to...
Read more >
grunt-cli - npm
The Grunt command line interface. Install this globally and you'll have access to the grunt command anywhere on your system.
Read more >
You don't need global grunt - Gleb Bahmutov
It is simple to get started, has tonnes of plugins, but requires a global installation. npm install -g grunt-cli. I hate requiring a...
Read more >
Using the CLI - Grunt: The JavaScript Task Runner
Run sudo npm install -g grunt-cli (Windows users should omit "sudo ", and may need to run the command-line with elevated privileges). The...
Read more >
Installing the Grunt CLI - Packt Subscription
NPM is used to install Grunt and the Grunt CLI. The process of installation is very simple. As we just completed the updating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found