'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?



Solution 1:[1]

npm install path
npm install stream

did the trick

Solution 2:[2]

in my case tried npm install path in terminal and it worked for me !

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lyslim
Solution 2 wassim meddeb