Unable to deploy 11ty site via Netlify due to fsevents platform error - npm

I'm trying to deploy my 11ty site via Netlify using Github for the continuous deployment however I'm unable to due to the following error:
8:12:37 PM: npm ERR! code EBADPLATFORM
8:12:37 PM: npm ERR! notsup Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
8:12:37 PM: npm ERR! notsup Valid OS: darwin
8:12:37 PM: npm ERR! notsup Valid Arch: undefined
8:12:37 PM: npm ERR! notsup Actual OS: linux
8:12:37 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
8:12:37 PM: npm ERR! notsup Actual Arch: x64
8:12:37 PM: npm ERR! A complete log of this run can be found in:
8:12:37 PM: npm ERR! /opt/buildhome/.npm/_logs/2023-01-02T20_12_36_805Z-debug-0.log
8:12:37 PM: Error during NPM install
8:12:37 PM: Build was terminated: Build script returned non-zero exit code: 1
8:12:37 PM: Failing build: Failed to build site
8:12:37 PM: Finished processing build request in 11.045830236s
I've tried deleting the package-lock.json file along with the node_modules directory and then re-triggering the deployment but that still throws the same error.
I've also added --omit=optional flag to the npm install command but still no luck.
I develop locally on my Mac and from what I can tell the fsevents package is installed via a separate dependancy to do with file watching. I think it's installed due to the below section of the package-lock.json file (hence why I thought the --omit=optional flag would solve the issue):
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
Has anyone seen this before and know of a fix?
Thanks in advance!

Related

Error Installing Gatsby Starter 'Something went wrong installing the "sharp" module'

Problem
I am trying to set up a Gatsby starter project on Windows. Specifically, this starter project: https://www.gatsbyjs.com/starters/hasura/gatsby-gitbook-starter/
Versions:
Node: v14.10.1
npm: 6.14.8
Gatsby CLI version: 2.12.99
Gatsby version: 2.18.10
Initial Steps that created error:
I opened a new terminal and ran the Gatsby Starter script according to the documentation:
"gatsby new gatsby-gitbook-starter https://github.com/hasura/gatsby-gitbook-starter"
After the initial starter is cloned successfully I am instructed to cd into the directory and run "gatsby-develop".
This throws the following error:
success open and validate gatsby-configs - 0.081s
ERROR
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'
Require stack:
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\sharp\lib\constructor.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\sharp\lib\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\safe-sharp.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby-plugin-sharp\gatsby-node.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\bootstrap\index.js
- C:\code\Sutro\gatsby-gitbook-starter2\node_modules\gatsby\dist\commands\develop.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js
- C:\Users\mxgel\AppData\Roaming\npm\node_modules\gatsby-cli\cli.js
- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
⠋ load plugins
My hunch is that this error is being thrown because of some global package manager configuration that I can't figure out, not the Sharp dependency itself. My goal is to use this Gatsby starter to streamline the process of project documentation.
Describe what you’ve tried
Followed Error Recommendations
My first step was to try the recommendation thrown by the error itself.
I tried removing the node_modules/sharp directory and running npm install but it gave me no errors and did not fix the problem. Its output from the NPM install was as follows.
added 2 packages from 60 contributors and audited 2713 packages in 12.906s
54 packages are looking for funding
run `npm fund` for details
found 1219 vulnerabilities (1168 low, 2 moderate, 49 high)
run `npm audit fix` to fix them, or `npm audit` for details
Removed Sharp Module, Reinstalled with Verbose Flag
Assuming that the 'verbose' flag would help, I removed the module and package-lock.json and ran npm install sharp --verbose:
npm info it worked if it ends with ok
npm verb cli [
npm verb cli 'C:\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\mxgel\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli 'sharp',
npm verb cli '--verbose'
npm verb cli ]
npm info using npm#6.14.8
npm info using node#v14.10.1
npm verb npm-session 166ad6819380c39e
npm http fetch GET 304 https://registry.npmjs.org/sharp 240ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/sharp/-/sharp-0.26.1.tgz 103ms (from cache)
npm timing stage:loadCurrentTree Completed in 3562ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 44ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 938ms
npm http fetch GET 304 https://registry.npmjs.org/semver 85ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/fsevents 114ms (from cache)
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm http fetch GET 304 https://registry.npmjs.org/bindings 145ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/file-uri-to-path 101ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 8627ms
npm timing stage:loadIdealTree Completed in 10371ms
npm timing stage:generateActionsToTake Completed in 190ms
npm verb correctMkdir C:\Users\mxgel\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb makeCacheDir UID & GID are irrelevant on win32
npm verb lock using C:\Users\mxgel\AppData\Roaming\npm-cache\_locks\staging-cfcdc7ee6147183b.lock for C:\code\Sutro\gatsby-gitbook-starter2\node_modules\.staging
npm timing action:extract Completed in 291ms
npm timing audit submit Completed in 321ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 324ms
npm timing audit body Completed in 4ms
npm timing action:finalize Completed in 19ms
npm timing action:refresh-package-json Completed in 93ms
npm info lifecycle file-uri-to-path#1.0.0~preinstall: file-uri-to-path#1.0.0
npm info lifecycle bindings#1.5.0~preinstall: bindings#1.5.0
npm info lifecycle semver#7.3.2~preinstall: semver#7.3.2
npm info lifecycle sharp#0.26.1~preinstall: sharp#0.26.1
npm timing action:preinstall Completed in 7ms
npm info linkStuff file-uri-to-path#1.0.0
npm info linkStuff bindings#1.5.0
npm info linkStuff semver#7.3.2
npm verb linkBins [
npm verb linkBins { semver: 'bin/semver.js' },
npm verb linkBins 'C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\sharp\\node_modules\\.bin',
npm verb linkBins false
npm verb linkBins ]
npm info linkStuff sharp#0.26.1
npm timing action:build Completed in 68ms
npm info lifecycle file-uri-to-path#1.0.0~install: file-uri-to-path#1.0.0
npm info lifecycle bindings#1.5.0~install: bindings#1.5.0
npm info lifecycle semver#7.3.2~install: semver#7.3.2
npm info lifecycle sharp#0.26.1~install: sharp#0.26.1
npm info lifecycle sharp#0.26.1~install: ignored because ignore-scripts is set to true sharp#0.26.1
npm timing action:install Completed in 32ms
npm info lifecycle file-uri-to-path#1.0.0~postinstall: file-uri-to-path#1.0.0
npm info lifecycle bindings#1.5.0~postinstall: bindings#1.5.0
npm info lifecycle semver#7.3.2~postinstall: semver#7.3.2
npm info lifecycle sharp#0.26.1~postinstall: sharp#0.26.1
npm timing action:postinstall Completed in 46ms
npm verb unlock done using C:\Users\mxgel\AppData\Roaming\npm-cache\_locks\staging-cfcdc7ee6147183b.lock for C:\code\Sutro\gatsby-gitbook-starter2\node_modules\.staging
npm timing stage:executeActions Completed in 648ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 15394ms
npm verb saving [ { name: 'sharp', spec: '^0.26.1', save: 'dependencies' } ]
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle gatsby-gitbook-boilerplate#0.0.1~shrinkwrap: gatsby-gitbook-boilerplate#0.0.1
npm notice created a lockfile as package-lock.json. You should commit this file.
npm info lifecycle gatsby-gitbook-boilerplate#0.0.1~postshrinkwrap: gatsby-gitbook-boilerplate#0.0.1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\babel-plugin-add-module-exports\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.1.1 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm WARN acorn-class-fields#0.2.1 requires a peer of acorn#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN acorn-dynamic-import#4.0.0 requires a peer of acorn#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils#3.17.1 requires a peer of typescript#>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must
install peer dependencies yourself.
+ sharp#0.26.1
added 4 packages from 66 contributors and audited 2666 packages in 16.799s
60 packages are looking for funding
run `npm fund` for details
found 1206 vulnerabilities (1157 low, 2 moderate, 47 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm verb exit [ 0, true ]
npm timing npm Completed in 18411ms
npm info ok
Existing Stack Overflow Solutions
After some research, I found that ignoring scripts might be the issue. I've tried setting ignore-scripts to true using the following command:
npm install sharp --ignore-scripts
This still did not fix the issue, and threw the same error.
The, I tried deleting my entire node modules folder and the package-lock.json, and then the following command:
npm install --unsafe-perm
The Sharp Error was still thrown after using 'gatsby develop'
Some more research. Again, trying to see if it was related to NPM, I ran the following to no avail:
npm rebuild
I Even Tried Yarn
Removing all of my modules and retrying the entire process using yarn did not fix the issue. I'm only listing this as an attempt to illustrate my desperation. I can post some of the yarn results, but long story short the Sharp module just straightup refuses to let me download a certain package from the Sharp module when using the Yarn install methods. I was even able to trace it down to the exact tvg module that refused to download, but I have no way of fixing this.
Thanks again for your time and patience, and info helps!
#Ferran pointed me in the best direction: the Gatsby documentation.
Not sure what caused this error, but I completely reset my Windows 10 and then reinstalled Node, NPM, Gatsby from scratch.
All commands working fine now, with no sharp module errors! Must have been some environment conflicts on my drive.

jsreport phamtom-pdf will failed if added in package.json

If I run the npm install even with root permission, the following package.json from jsreport will fail with mkdir permission error from phamtom-pdf related packages
{
"name": "jsreport-server",
"main": "server.js",
"scripts": {
"start": "node server",
"jsreport": "jsreport"
},
"jsreport": {
"entryPoint": "server.js"
},
"dependencies": {
"jsreport": "2.3.0",
"jsreport-phantom-pdf": "^2.1.4"
}
}
Remove the jsreport-phantom-pdf dependency and install it manually later is fine but it seemed weird and defeat the purpose of package.json.
--------Edit-------
npm WARN deprecated npmconf#2.1.1: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated npmconf#2.0.9: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated graceful-fs#3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm WARN deprecated hoek#0.9.1: The major version is no longer supported. Please update to 4.x or newer
> phantomjs#1.9.15 install /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs
> node install.js
invalid config loglevel="notice"
/home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/phantomjs is not writable: EACCES: permission denied, mkdir '/home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/phantomjs'
Download already available at /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Extracting tar contents (via spawned process)
Removing /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1547027030055/phantomjs-1.9.8-linux-x86_64 -> /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs
> puppeteer#1.11.0 install /home/chnn/jsreport_git/node_modules/puppeteer
> node install.js
ERROR: Failed to download Chromium r609904! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/home/chnn/jsreport_git/node_modules/puppeteer/.local-chromium'
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/home/chnn/jsreport_git/node_modules/puppeteer/.local-chromium' }
npm WARN jsreport-server# No description
npm WARN jsreport-server# No repository field.
npm WARN jsreport-server# No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#1.11.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#1.11.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/chnn/.npm/_logs/2019-01-09T09_43_52_509Z-debug.log
This is a known bug with the installer of puppeteer, see issue#367 and issue #375
You can try the workaround as mentioned by BennySLO
sudo npm install puppeteer --unsafe-perm=true
sudo chown -R <username> node_modules/

No compatible version found: grunt-contrib-concat#'node_modules/grunt-contrib-concat'

I recently received website that consists of an index.html, sass files, javascript files and a few configuration files. I tried to run the command npm install in the main project directory and I got the following error.
npm ERR! Error: No compatible version found: grunt-contrib-concat#'node_modules/grunt-contrib-concat'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.3.0","0.4.0","0.5.0","0.5.1","1.0.0","1.0.1","0.1.2-rc5","0.1.2-rc6"]
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:719:10)
npm ERR! at /usr/share/npm/lib/cache.js:638:10
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 4.4.0-x86_64-linode63
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /var/www/project.com/public_html_staging
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/www/project.com/public_html_staging/npm-debug.log
npm ERR! not ok code 0
This is what my package.json looks like
{
"name": "project",
"version": "0.0.0",
"devDependencies": {
"glob": "~4.3.1",
"grunt": "~0.4.1",
"grunt-autoprefixer": "~2.0.0",
"grunt-concat-css": "^0.3.1",
"grunt-contrib-concat": "node_modules/grunt-contrib-concat",
"grunt-contrib-connect": "~0.9.0",
"grunt-contrib-cssmin": "~0.11.0",
"grunt-contrib-imagemin": "^1.0.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-sass": "~0.8.1",
"grunt-contrib-uglify": "~0.7.0",
"grunt-contrib-watch": "~0.6.1"
},
"dependencies": {
"load-grunt-tasks": "~2.0.0"
}
}
I'm really new to the npm command and any related subject matter. How do I begin to troubleshoot this error? Or does anyone know the solution?
The problem was caused by the fact that I was using NodeJS version 0.1 while the project was originally built on a server that had NodeJS v5. Hence the npm didn't have all the right grunt dependencies.
I did the following as root user on my affected server
apt-get purge nodejs
apt-get purge npm
apt-get autoremove // remove any orphan dependences
Once I got rid of everything, I install version 6 of NodeJS as per the nodejs website with these commands:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
The NodeJS already came with it's own npm, so I didn't need to do anything else.
Then when I ran npm install, it properly downloaded all the necessary modules to run my project.

Grunt won't install on my project

I've been trying to install grunt on my project but no luck.
Here's the error i get when running npm install
npm WARN package.json XXX#1.0.0 No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-contrib-copy#0.8.2 wants grunt#>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-sass#0.9.2 wants grunt#>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-watch#0.6.1 wants grunt#~0.4.0
npm ERR! peerinvalid Peer grunt-mustache-render#1.9.0 wants grunt#^0.4.5
Heres' what my package json looks like
{
"name": "XXX",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "some git repo"
},
"devDependencies": {
"grunt-html-build": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-mustache-render": "^1.9.0"
}
}
I've tried npm update -g but nothing much seems to happen.
npm --version says 2.11.3
the only relevant error i think i found was when i ran
> npm list
├─┬ grunt#1.0.1 peer invalid
and at the end: npm ERR! peer invalid: grunt#1.0.1
> grunt --version
grunt-cli v1.2.0
grunt v1.0.1
do i need to re-install grunt or something ? I haven't found a command for that.
Thanks for your help!
Some grunt-plugins haven't updated their peer dependency requirements yet to work with the 1.0 version of grunt (1.0 is fairly new). You can try to remove the peer dependency requirements, but that could be problematic depending on what changes were made between 0.4.5 and 1.0. (0.4.5 was the last version prior to 1.0)
Try installing the version of grunt that's compatible with the plugins first: npm install grunt#^0.4.5 --save-dev
For npm version 2, you should have grunt version 0.4.5
"devDependencies": {
"grunt": "^0.4.5" }
As you seen below , npm version is less than 3 so you should have grunt version: ^0.4.5
$ npm --version
2.15.11
Output from npm install explains everything pretty good:
npm ERR! peerinvalid Peer grunt-contrib-copy#0.8.2 wants grunt#>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-sass#0.9.2 wants grunt#>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-watch#0.6.1 wants grunt#~0.4.0
npm ERR! peerinvalid Peer grunt-mustache-render#1.9.0 wants grunt#^0.4.5
To understand it you need to understand semantical versioning explained here:
https://docs.npmjs.com/files/package.json#version
and here
https://docs.npmjs.com/misc/semver
In order to fix the problem you must specify more flexible version number for packages that block installation of new grunt.
Just set ">= 0.0.0" requirement for all grunt plugins and their versions will be synchronized with grunt version by npm.
"devDependencies": {
"grunt-html-build": ">=0.0.0",
"grunt-contrib-copy": ">=0.0.0",
"grunt-contrib-sass": ">=0.0.0",
"grunt-contrib-watch": ">=0.0.0",
"grunt-mustache-render": ">=0.0.0"
}

How do I Properly run NPM Install in Visual Studio Team Services Build Agent

I'm having trouble setting up an NPM task for an automated build in Visual Studio Team Services (previously Visual Studio Online). There are two problems:
Cache locking errors (shown below).
It is painfully slow -- 45+ minutes for a dozen or so packages.
I added the --cache argument but that did not seem to help.
npm install --dev --cache $(Agent.BuildDirectory)\b
The binaries folder seems like the right spot for the cache, but honestly, I'm not sure. Some documentation here:
https://msdn.microsoft.com/Library/vs/alm/Build/scripts/variables#AgentVariables
I appreciate any advice...
Current Config:
Build console output:
Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\tasks\Npm\0.2.7
##[debug]check path : C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\tasks\Npm\0.2.7\task.json
##[debug]set resource file to: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\tasks\Npm\0.2.7\task.json
##[debug]system.culture=en-US
##[debug]check path : C:\Program Files\nodejs\npm.cmd
##[debug]npm=C:\Program Files\nodejs\npm.cmd
##[debug]cwd=C:\a\1\s\com.example.web
##[debug]path exists: C:\a\1\s\com.example.web
##[debug]command=install
##[debug]C:\Program Files\nodejs\npm.cmd arg: install
##[debug]arguments=--dev --cache C:\a\1\b
##[debug]C:\Program Files\nodejs\npm.cmd arg: --dev --cache C:\a\1\b
##[debug]exec tool: C:\Program Files\nodejs\npm.cmd
##[debug]Arguments:
##[debug] install
##[debug] --dev
##[debug] --cache
##[debug] C:\a\1\b
[command]C:\Program Files\nodejs\npm.cmd install --dev --cache C:\a\1\b
npm WARN deprecated graceful-fs#3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated sf-lint#1.0.2: Use eslint-config-simplifield instead.
npm WARN deprecated lodash#2.4.1: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN deprecated lodash#0.9.2: Grunt needs your help! See https://github.com/gruntjs/grunt/issues/1403.
npm ERR! addLocal Could not install C:\a\1\s\com.example.web\#shinnn\eslint-config#>=0.0.5 <0.0.6\fixtures
npm WARN deprecated phantomjs#2.1.3: Package renamed to phantomjs-prebuilt. Please update 'phantomjs' package references to 'phantomjs-prebuilt'
npm WARN peerDependencies The peer dependency qunitjs#^1.14.0 included from karma-qunit will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN package.json Dependency 'mocha' exists in both dependencies and devDependencies, using 'mocha#*' from dependencies
npm WARN package.json Dependency 'mocha' exists in both dependencies and devDependencies, using 'mocha#*' from dependencies
npm ERR! addLocal Could not install C:\a\1\s\com.example.web\#shinnn\eslint-config#>=0.0.4 <0.0.5\fixtures
> cson#1.6.2 preinstall C:\a\1\s\com.example.web\node_modules\gulp-uglify\node_modules\uglify-save-license\node_modules\grunt-replace\node_modules\applause\node_modules\cson
> node ./cyclic.js
npm WARN locking Error: EMFILE, open 'C:\a\1\b\_locks\strip-ansi-0bb45da2369f5768.lock.STALE.STALE.STALE'
npm WARN locking at Error (native)
npm WARN locking C:\a\1\b\_locks\strip-ansi-0bb45da2369f5768.lock failed { [Error: EMFILE, open 'C:\a\1\b\_locks\strip-ansi-0bb45da2369f5768.lock.STALE.STALE.STALE']
npm WARN locking errno: -4066,
npm WARN locking code: 'EMFILE',
npm WARN locking path: 'C:\\a\\1\\b\\_locks\\strip-ansi-0bb45da2369f5768.lock.STALE.STALE.STALE' }
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--dev" "--cache" "C:\\a\\1\\b"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
2016-03-30T14:15:17.4509244Z npm ERR! Attempt to unlock C:\a\1\s\com.example.web\node_modules\gulp-imagemin\node_modules\imagemin-pngquant\node_modules\pngquant-bin\node_modules\compare-size\node_modules\ava\node_modules\chalk\node_modules\strip-ansi, which hasn't been locked
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm WARN locking Error: EMFILE, open 'C:\a\1\b\_locks\ansi-styles-cedcc1e1e4774cd0.lock.STALE.STALE.STALE'
npm WARN locking at Error (native)
npm WARN locking C:\a\1\b\_locks\ansi-styles-cedcc1e1e4774cd0.lock failed { [Error: EMFILE, open 'C:\a\1\b\_locks\ansi-styles-cedcc1e1e4774cd0.lock.STALE.STALE.STALE']
npm WARN locking errno: -4066,
npm WARN locking code: 'EMFILE',
npm WARN locking path: 'C:\\a\\1\\b\\_locks\\ansi-styles-cedcc1e1e4774cd0.lock.STALE.STALE.STALE' }
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--dev" "--cache" "C:\\a\\1\\b"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! Attempt to unlock C:\a\1\s\com.example.web\node_modules\gulp-imagemin\node_modules\imagemin-pngquant\node_modules\pngquant-bin\node_modules\compare-size\node_modules\ava\node_modules\chalk\node_modules\ansi-styles, which hasn't been locked
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm WARN locking Error: EMFILE, open 'C:\a\1\b\_locks\has-ansi-819c7cca16ab7ac8.lock.STALE.STALE.STALE'
npm WARN locking at Error (native)
2016-03-30T14:15:17.5709240Z npm WARN locking C:\a\1\b\_locks\has-ansi-819c7cca16ab7ac8.lock failed { [Error: EMFILE, open 'C:\a\1\b\_locks\has-ansi-819c7cca16ab7ac8.lock.STALE.STALE.STALE']
Re-installing NPM solved my issue:
npm install npm -g
Specifically, I added the circled task to my build: