Reputation: 109
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?
Upvotes: 5
Views: 26347
Reputation: 1
node modules act as a library to the file which we have to use in the directory of the project. It simply provides all dependencies that are required to run a project but, package.json acts as an abstract layer that only holds the version of that dependencies, deleting node modules would not affect the package.json but the project still holds its version of the dependencies version. So if you want to use some other version of those dependencies Either delete the package.json and install all libraries of that project then delete node modules and then reinstall all (node modules)and make package.json again by Command
npm uninstall --save <package> name
npm i
npm i <package name>
Upvotes: 0
Reputation: 476
Nothing bad, you can easily delete it and then reinstall everything via
npm i
in console. You can see here details about deleting it:https://medium.com/@MarkPieszak/how-to-delete-all-node-modules-folders-on-your-machine-and-free-up-hd-space-f3954843aeda
Upvotes: 1
Reputation: 1496
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.
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.
Upvotes: 7