Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm getting an error after installing any package via npm. Every time I serve my application through ng serve, it gives me an error saying Error: Type [packageName] does not have '?mod' property. What should I do?

I guess if I delete my node_modules folder and re-create it via npm install command, it would be resolved.

Anybody can suggest if I delete node_modules folder and after re-creating it, will I get all the already installed packages back in the same way they were just before deleting?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
483 views
Welcome To Ask or Share your Answers For Others

1 Answer

if i delete node_modules folder and after re-creating it, will i get all the already installed packages back in the same way they were just before?

answer is yes.

or you can do it with

npm ci

its faster and do the same job.

but what if problem is with your package-lock?

your team commited package-lock.json and in merge or somehow its not the correct.

here you need to remove package-lock too.

now getting packages same as they were beforedepends on your package.json.

look at this package.json

{
  "name": "awesome-app",
  "version": "1.0.0",
  "description": "",
  "main": "dist/index.js",
  "scripts": {
   .
   .
   .
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "angular": "^1.8.1"
   },
}

every time i run npm install, because of "^", npm looks for last angular release which match 1.X.X version and update your package to that version.

enter image description here

if we see angular versions on npm website, angular released 1.8.2 one month after 1.8.1 . so this depends on when you are installing and how did you specify version range.

read more about npm flags


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...