Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Error: Can't resolve 'path'

I have an Angular CLI project which I just upgraded to Angular 6. Now when I try to build my app, I get the following errors:

ERROR in ./node_modules/postcss/lib/input.js Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib' ERROR in ./node_modules/postcss/lib/map-generator.js Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib' ERROR in ./node_modules/postcss/lib/previous-map.js Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib' ERROR in ./node_modules/htmlparser2/lib/WritableStream.js Module not found: Error: Can't resolve 'stream' in '/Users/jattardi/code/myproject/node_modules/htmlparser2/lib'

I'm confused. First off, I am not even using postcss or htmlparser2 directly in my project. So they must be dependencies of something else.

But aren't path and stream built in Node modules? How could it not be able to resolve them?

like image 308
Joe Attardi Avatar asked May 18 '18 00:05

Joe Attardi


People also ask

How do you fix module not found error Cannot be resolved?

To solve the "Module not found: Can't resolve" error in React, make sure to install the package from the error message if it's a third-party package, e.g. npm i somePackage . If you got the error when importing local files, correct your import path.

How to solve module not found error in node js?

If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.

What is module not found error in react js?

A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies. The module you're trying to import is in a different directory. The module you're trying to import has a different casing.

How do I resolve node modules error?

To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.


1 Answers

npm install path
npm install stream

did the trick

like image 155
lyslim Avatar answered Sep 20 '22 03:09

lyslim