problem installing postcss-grid-kiss and gulp-postcss


(Max Waterman) #1

I want to try out a postcss-grid-kiss, and to install that I need to do:

npm install postcss-grid-kiss --save-dev

but I get:

npm WARN @babel/plugin-transform-classes@7.0.0-beta.35 requires a peer of @babel/core@7.0.0-beta.35 but none is installed. You must install peer dependencies yourself.

npm ERR! err.code.match is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/davidmaxwaterman/.npm/_logs/2019-02-20T13_49_09_569Z-debug.log

I get the same output from npm install gulp-postcss --save-dev.

$ node --version && npm --version
v8.12.0
6.8.0

It’s been a while since I tried to install any new packages - I’ve been doing npm ci, which works nicely.

Any ideas?

[NB: I see that it seems to work in an empty directory - after npm init]


Getting error while installing package.
(Lars Willighagen) #2

Can you post the debug log, or just the error stack trace (which can be found in the debug log)?


(Max Waterman) #3

The file is 6416 lines long, and the stack trace is (predictably) at the end:

668 warn @babel/plugin-transform-classes@7.0.0-beta.35 requires a peer of @babel/core@7.0.0-beta.35 but none is installed. You must install peer dependencies yourself.
669 verbose stack TypeError: err.code.match is not a function
669 verbose stack     at BB.try.catch.err (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/pacote/lib/with-tarball-stream.js:110:55)
669 verbose stack     at tryCatcher (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
669 verbose stack     at Promise._settlePromiseFromHandler (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
669 verbose stack     at Promise._settlePromise (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
669 verbose stack     at Promise._settlePromise0 (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
669 verbose stack     at Promise._settlePromises (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:690:18)
669 verbose stack     at _drainQueueStep (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:138:12)
669 verbose stack     at _drainQueue (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:131:9)
669 verbose stack     at Async._drainQueues (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:147:5)
669 verbose stack     at Immediate.Async.drainQueues (/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
669 verbose stack     at runCallback (timers.js:810:20)
669 verbose stack     at tryOnImmediate (timers.js:768:5)
669 verbose stack     at processImmediate [as _immediateCallback] (timers.js:745:5)
670 verbose cwd /home/davidmaxwaterman/z/antenna/polymer_tourbuilder_client
671 verbose Linux 4.15.0-45-generic
672 verbose argv "/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/bin/node" "/home/davidmaxwaterman/.nvm/versions/node/v8.12.0/bin/npm" "install" "postcss-grid-kiss" "--save-dev"
673 verbose node v8.12.0
674 verbose npm  v6.8.0
675 error err.code.match is not a function
676 verbose exit [ 1, true ]

The complete file is here:

http://davidmaxwaterman.fastmail.co.uk/bugs/2019-02-20T13_49_09_569Z-debug.log


(Lars Willighagen) #4

The error seems to be caused by apparently incorrect assumptions in error handling. Looking at the full log, the original error it’s having problems with is caused by the gulp github dep (gulp@github:gulpjs/gulp#71c094a51c7972d26f557899ddecab0210ef3776). At least, that’s the only one that isn’t successfully extracted. However, I don’t see the same problem when installing just that package in a new project myself, can you try?


(Max Waterman) #5

can you try?

I’m not sure /exactly/ what you’re asking, but I think this:

08:03:22 ~$ mkdir tmp
08:03:26 ~$ cd tmp
08:03:27 ~/tmp$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (tmp) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /home/davidmaxwaterman/tmp/package.json:

{
  "name": "tmp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) 
08:03:37 ~/tmp$ npm install postcss-grid-kiss --save-dev
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN tmp@1.0.0 No description
npm WARN tmp@1.0.0 No repository field.

+ postcss-grid-kiss@2.1.2
added 20 packages from 46 contributors and audited 33 packages in 4.73s
found 0 vulnerabilities

08:04:25 ~/tmp$ ls
node_modules  package.json  package-lock.json
08:04:38 ~/tmp$ ls node_modules/
ansi-styles   caniuse-lite  color-convert  css-unit-converter    escape-string-regexp  node-releases  postcss-grid-kiss            postcss-value-parser  semver      supports-color
browserslist  chalk         color-name     electron-to-chromium  has-flag              postcss        postcss-merge-grid-template  reduce-css-calc       source-map
08:04:42 ~/tmp$ npm install gulp-postcss --save-dev
npm WARN tmp@1.0.0 No description
npm WARN tmp@1.0.0 No repository field.

+ gulp-postcss@8.0.0
added 33 packages from 75 contributors and audited 78 packages in 5.822s
found 0 vulnerabilities

08:05:16 ~/tmp$ ls node_modules/
ansi-colors  arr-union       color-name            escape-string-regexp  import-cwd     is-plain-object           plugin-error                 reduce-css-calc      supports-color
ansi-gray    assign-symbols  color-support         esprima               import-from    json-parse-better-errors  postcss                      require-from-string  time-stamp
ansi-styles  browserslist    cosmiconfig           extend-shallow        is-arrayish    js-yaml                   postcss-grid-kiss            resolve-from         vinyl-sourcemaps-apply
ansi-wrap    caniuse-lite    css-unit-converter    fancy-log             is-directory   node-releases             postcss-load-config          semver
argparse     chalk           electron-to-chromium  gulp-postcss          is-extendable  parse-json                postcss-merge-grid-template  source-map
arr-diff     color-convert   error-ex              has-flag              isobject       parse-node-version        postcss-value-parser         sprintf-js
08:06:26 ~/tmp$ 

IE, that all works as expected, I think. So, it is perhaps an incompatibility with my project’s existing dependencies?


(Max Waterman) #6

I seem to get success if I remove the #4.0, in my package.json:

"gulp": "gulpjs/gulp#4.0",

ie:

"gulp": "gulpjs/gulp",

and remove package-lock.json followed by a fresh npm install.

After that:

10:07:58 {apt-1789-pwa-specific-pages} ~/z/antenna/polymer_tourbuilder_client$ npm install postcss-grid-kiss gulp-postcss --save-dev
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ postcss-grid-kiss@2.1.2
+ gulp-postcss@8.0.0
added 25 packages from 56 contributors and audited 22775 packages in 12.862s
found 28 vulnerabilities (19 low, 7 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details

I need to test everything (all looks good so far), but I count that as a success.

I wonder what you think of what happened. I’ve been doing just ‘npm ci’ for so long, perhaps I should have done a ‘npm install’ before attempting to install something new?


(John Gee) #7

I am adding a reply prompted by the “if I remove the #4.0”. Credit to @larsgw for identifying gulp as possible cause.

I suspect someone may have made a manual edit to an incorrect form for the git remote url specification, or there was a “4.0” branch which has been deleted.

I did some investigation of the format using npm install and https://docs.npmjs.com/cli/install

npm install <git remote url>
...
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
npm install "gulp@github:gulpjs/gulp#4.0"
# fails, does not match a commit-ish as the tag is v4.0.0
npm install "gulp@github:gulpjs/gulp#v4.0.0"
# succeeds
npm install "gulp@github:gulpjs/gulp#semver:4.0"
# succeeds (clever!)

(Max Waterman) #8

Interesting. Thanks for looking into it.

According to git, that line hasn’t been changed since 2017-11-13 15:08:09 +08…so, I imagine there was actually a 4.0 branch or tag, which is now no more.
I find it difficult to believe I’ve not done an npm install since then. I’ve been doing npm ci for quite some time (it’s been a revelation since package-log.json was introduced, which I found to be a pita), but Nov '17 is a long time ago…

The error is a bit obscure. I’ll be sure to look more closely in the log.

Anyway, all good now, thanks to both of you! :D


(John Gee) #9

I found a 4.0 branch in a fork of gulp, so confirms the branch being deleted is a good story for the trigger: https://github.com/4979/gulp/branches

(There is probably an error in the error handling, making it extra obscure. :slight_smile: )


(Max Waterman) #10

Lol, good detective work there :D


(Lars Willighagen) #11

I made a PR for the error handling. The real error is

npm ERR! code 1
npm ERR! Command failed: git checkout 4.0
npm ERR! error: pathspec '4.0' did not match any file(s) known to git

Which might not be very helpful either if you have a lot of dependencies, but it’s an improvement.

MCVE

Not sure if this depends on cache state too…

package.json:

{
  "name": "a",
  "version": "1.0.0",
  "dependencies": {
    "gulp": "gulpjs/gulp#4.0"
  }
}

package-lock.json:

{
  "name": "a",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "gulp": {
      "version": "github:gulpjs/gulp#71c094a51c7972d26f557899ddecab0210ef3776",
      "from": "github:gulpjs/gulp#4.0"
    }
  }
}

(system) closed #12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.