Town of passion ошибка cannot read property match of undefined

Обновлено: 04.07.2024

npm it to get my local install of modular-css up-to-date.

  • npm@6.1.0
  • node@8.11.2
  • Windows 10 build 14393

3 Answers 3

npm cache clear --force

and try to run the command:


2,901 2 2 gold badges 31 31 silver badges 47 47 bronze badges

It worked for me!

  1. vue create new-project
  2. vue add vuetify

But I got ERROR TypeError: Cannot read property 'match' of undefined.

it is related to this commit

so just go to your vue_project/node_modules/vuetify-loader/lib/plugin.js and change code manually

Don't worry The Vuetify team performs releases on a weekly basis. Fix is committed so it will be solved in next release

I'm new to Node JS and am trying to set up a basic application that fetches my inbox (outlook) contents in JSON format. I tried using match function to filter the data based on subject but I keep getting this error -

I tried using other string functions as well but keep getting similar errors.

I am able to print 'json.value[i].Subject' in console but cannot use it in match function.

I expect the match function to work so that I can filter based on Subject (json.value[i].Subject) but I guess I missed out something.

However I am able to get results if I hard code some string to compare with the Subject.

Clearing the cache

That can work if the cache get currupted somehow! But the common error is more of Unexpected end of JSON input while parsing near .

How to test fast and also switch nodejs version quickly

To be fast at testing this and checking! Mostly for any internal error that will come! I'll google it quickly! And try another version of nodejs or whatever in question (ex: typescript)! I can too debug (console.log) The internal file where the error was thrown! And try to figure out something!

But that's it! It's really interesting to check for other versions! (nodejs, typescript, . [remember be skeptical or alerted])

For nodejs To do it quickly:

NVM to switch quickly nodejs versions (npm)

Use NVM (nvm is a version manager for node.js,)

Quick installation of version in NVM

Quick switch to another node version

(Check the doc for the details! And installation process)

For switching and testing some npm module version (ex: typescript)

If it's a cli tool! you can install a precise version globaly

use the @ syntax!

Once you verify and test you can switch back to whatever you like!

If it's in a project! You can do the same (not globally)! use the @ syntax to precise the version!

Last tip (use npx in your scripts)

It's nice to set a version internal to the project! For example

In scripts i use npx:

When we use npx this way with a nodjes module cli tool! npx will check first if the module is available in the local node_modules! If found will use it (use global otherwise, or Download latest and run)!

So doing what i'm suggesting! Will make sure your project will run independently from whatever you have in global!

ERROR TypeError: Cannot read property 'match' of undefined.

npm build fails saying 'match' of undefined. I gave the error details and the package.json file.

FYI, I tried to remove the package-lock.json & node_nodules then gave install and build. but still its not working.


12k 10 10 gold badges 25 25 silver badges 41 41 bronze badges 90 1 1 gold badge 2 2 silver badges 8 8 bronze badges

Removing node_modules

(NOTICE: that may still not work)

You can try to remove package.lock too!

Fix Our problem ( Cannot read property 'matches' of undefined )

If you are using node v15! Try with node v14 (npm v6.14.8)! That may be it! An npm bug! That's a first thought can be! That what i thought at first!

That's was the case for me! In this last problem! I tried all the solutions that i'm familiar with! And they were already listed here too! None worked! And more when i removed node_modules! I was Please not another version HELL ! And yea it was exactly that! It worked well with **node v14** (npm v6.14.8) . Which suggest a [BUG].

Then reflecting a bit on it! It was like hey! When i change the version! I'm using another nodejs installation! Which can just not have the problem. A problem with npm structure or something and a re-installation may fix it (as mentioned above)!

After it ! I tried with node v15.3.0 . And it worked all ok! After the installation was all right done! I went back to node v15.0.1! And it worked again! So the problem is absolutely not a VERSION HELL problem

I'm still uncapable to explain what did happen! But in short! Using NVM! To try with another version! Is a good way to go about it! You can reinstall quickly the current version too!

Big Take down (for the VERSION HELL)

Starting from nodejs v14! And v15! Or just generally! It's nice to be skeptical about the versions! More of a reason when it doesn't make sense! And that's about all the problems not just npm! There is so many VERSIONS HELL problems! I encountred 2 up to now! Being alerted to the VERSIONS HELL can save you a lot of time!

5 Answers 5

Try removing your package-lock.json to see if that helps.

Edit: If the issue still persists, delete node_modules as well.

1,244 2 2 gold badges 9 9 silver badges 26 26 bronze badges Try removing node_modules as well. rm -rf node_modules after cd-ing into your app directory. Use del package-lock.json command on Windows OS. Also close editors and delete node_modules . Both are must. This is just a temporary solution. I believe it would be great to provide a solution that permanently fixes the issue based on the inputs provided by author of the question

You have to remove both package-lock.json and node_modules/ .

If you don't remove both, the problem will come back on the next npm install .


1,657 1 1 gold badge 15 15 silver badges 21 21 bronze badges This should be the accepted answer. The question is why this happens?

I had the same error when running npm install in my repo. I don't use Jenkins, but I found a generic approach to debugging (and ultimately resolving) this issue in NPM.

Note that in my case, the underlying issue (of the missing package.json file) appears to have been caused by me accidentally running npm install from the parent project (which uses my firebase-feedback library), while I had that library "npm linked".

I normally use npm-safe-install to avoid these sorts of issues (when using npm link ), but I must have forgotten sometime recently -- leading to NPM mangling the npm-linked libraries' node_modules folders.

Similar issues relating to npm link have happened before, but I hoped NPM would have patched these sorts of issues by now. Apparently not; though version 7 of NPM has been stated as going to have a rewrite in that area, so hopefully that will solve it long term.

10.1k 7 7 gold badges 56 56 silver badges 68 68 bronze badges

You have to remove project Package-lock.json file. then try to install what you want.

You can find that file in main project directory


The error may vary on what npm internals file it can be thrown! (And i wonder for all the possible reasons)! And it should be a bug!

(in my last case: it was on [_canPlaceDep] method of the file build-ideal-tree.js of npm!

If none of the common methods works! And that you are using nodejs v15+ and one of latest npm version! Go to the last part! The problem that i call the nodejs VERSIONS HELL! (NOTE: after reflection! For npm it may not be a version HELL! READ TO KNOW)

Removing package.lock (which is not adviced)

Why not advised

From @DanielIM comment

No, it should not. This is "the recommended workaround" but is incredibly broken in practice. Having a locked dependency in package.json in no way ensures that dependency's dependencies will remain consistent, so removing the package-lock.json file, npm installing, and generating a newlock file *will allow those sub-dependencies to change, which often completely breaks any future building. Using an existing lock file is often the only way to maintain builds (that is the POINT of the file, after all) so removing it completely goes against the reason for its existence.

So generally it's nice to leave that as a last resort! If it does not work ! You can try with removing node_modules too!

A problem can happen at npm level! Trying to reinstall can be a nice way!

To test quickly in place of reinstalling! Using NVM (nodejs version manager) and switching to another version is fast and interesting! Because we can also test for VERSION HELL PROBLEM!

If it works after switch! Then either it's a problem with npm and a reinstallation may fix it! Or it's a version Hell problem (a bug)!

How to reinstall fast! Again use nvm!

You can just install another version and use it! (v14 for example)

Check the VERSION HELL PROBLEM And how to use nvm to switch between versions!

In this year! I encountered many nodejs VERSIONS HELL problems! (I like to call them that) (because i gave them a name! The skies are blessing me with more) (irony)

To list them quickly:

What Happened Instead

Reproduction Steps

Details

Couple of extra data points:

  1. I get the same error w/ a bare npm install
  2. If I delete package-lock.json the install will succeed w/o issue.

I can work around this for now by deleting my lockfile before every install and/or disabling the lockfile via config, but neither of those are really good choices.

  1. $ rm -rf package-lock.json node_modules <-- you need both
  2. $ npm install
  3. And you should be back up and running (at least, I can no longer repro it).

It looks like you have a weird/bad entry in the pkglock. I have no idea why the version disappeared from your package-lock.json , but this is probably why you’re getting this error:

Your package-lock.json is actually really messed up for some reason. It’s not just the above entry, and I don’t see an obvious way to have npm auto-repair this sort of thing. It’s broken enough that I don’t think it’s even worth adding such a patch. (/cc @iarna in case she thinks otherwise!) It might have to do with bundledDeps, plus your node_modules having gotten bad metadata in the process.

:slight_smile:

Let me know if the above doesn’t actually fix it for you. At the very least, you should be able to get back to work. And please let me know if you figure out how your pkglock even got like that. (and if this works for you, remember to mark this post as the solution!)

One thing I wonder about is whether it was because of treating it as binary, but I’ve no idea why that’d break it.

Thanks for taking a look @zkat!

Your fix definitely sorted it. Embarassed that I never thought to try deleting both the lockfile and node_modules , but oh well.

I’ve gone through various permutations of having a lock/vs not having a lock as well as using beta builds of lerna so it’s not all that surprising that it got horked up by something at some point. I’m just glad to be back up & running again!

Replied June 11, 2018 by doberkofler

@doberkofler You only mention removing the lock-file, but the directions here are to remove the lock-file AND the node_modules. Have you tried it with both?

@iarna Removing the lock file AND the node_modules folder worked for me. Only removing the lock file only worked once.

Task :api:processResources Task :api:classes Task :web:nodeSetup Task :web:npmSetup /var/lib/jenkins/workspace/hds_v2_docker/web/.gradle/npm/npm-v6.11.2/bin/npm -> /var/lib/jenkins/workspace/hds_v2_docker/web/.gradle/npm/npm-v6.11.2/lib/node_modules/npm/bin/npm-cli.js /var/lib/jenkins/workspace/hds_v2_docker/web/.gradle/npm/npm-v6.11.2/bin/npx -> /var/lib/jenkins/workspace/hds_v2_docker/web/.gradle/npm/npm-v6.11.2/lib/node_modules/npm/bin/npx-cli.js

  • npm@6.11.2 added 430 packages from 832 contributors in 6.837s

Task :web:npmInstall FAILED npm ERR! Cannot read property 'match' of undefined

npm ERR! A complete log of this run can be found in: npm ERR!
/var/lib/jenkins/.npm/_logs/2019-10-16T01_11_20_594Z-debug.log

  • What went wrong: Execution failed for task ':web:npmInstall'.

Process 'command '/var/lib/jenkins/workspace/hds_v2_docker/web/.gradle/npm/npm-v6.11.2/bin/npm'' finished with non-zero exit value 1

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

BUILD FAILED in 33s

/var/lib/jenkins/.npm/_logs/2019-10-16T01_11_20_594Z-debug.log

12.8k 9 9 gold badges 43 43 silver badges 67 67 bronze badges 507 1 1 gold badge 4 4 silver badges 7 7 bronze badges

Читайте также: