-
Notifications
You must be signed in to change notification settings - Fork 12k
ng build
fails with error Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
after updating to v1.3.0
#7334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@MarkTiedemann Had the same issue. Didn't install webpack as a workaround. Fixed it by replacing my package.json dependencies with those of a new app (ng new testapp) and reinstalling npm modules. Before reinstalling remove package-lock.json and run |
@filipesilva I believe it is necessary to have a way/script that will automatically update an app that was generated from a previous version of angular-cli. Something like this is possible. |
@filipesilva @hansl I do believe I can make a tool for angular-cli that will manage updates. It would detect changes between versions (apps generated with ng new) and apply them properly. (even if end-user has changed things) This would help to easily upgrade existing angular-cli projects. Some first features of this tool:
What do you think of this? If there is something already, or you have a better way of doing it, feel free to tell me. I just made a suggestion. |
@filipesilva comment that we should not add webpack to dependencies in package.json anymore it can cause various unexpected errors like this one with webpack version missmatch #6417. In my opinion auto updater tool is not that helpful especially when there is not that much to compare when upgrading a local @angular/cli version. Also I dont see why we should use auto updater of package.json according to new @angular/cli deps versions because its usually not relevant. For example @angular/cli@1.3.1 using @angular~4.2.4 but current version is 4.3.5. In this case ncu is more than enough. |
@valdestrijus During Angular-cli updates package.json is not the only file that could change. There are other changes that could happen in other config files also (tsconfig.json, karma.conf.js, angular-cli.json, tslint.json, protractor.conf.json, test.ts) If you don't change those files properly then your apps could have errors/issues. @valdestrijus Why not have an automated way that those files get updated? Why do you prefer users not updating their apps properly (by just changing the version in package.json ). This causes afterwards many unnecessary issues in this repo with complaints that things got broken. (while the problem was that they generally don't update their app properly) This causes unnecessary waste of time for the Angular-CLI team to deal with such issues which could had been avoided in the first place. |
Changing es2016 to es2017 in my root tsconfig.json file fixed this issue for me. But I totally agree with @nekkon. I like keeping up to date en trying out the new features so what I try and do is create a new app (ng new appname) and then look at all the files generated and see what changed from my files. But off course my files keep on changing with new stuff so its very difficult to compare. So looking forward to #7375 😄 |
@nekkon Sure there are like few more configs to update with each @angular/cli version, but i can bet that as the project grows all those configs are customized anyways. For example in karma.conf.js I always add different reporters for my project than it is in default @angular/cli project. Speaking about tslint.json configuration - you cant update it automatically because various teams have different rules for their projects and usually this config is customized. .editorconfig is also not used by every team and will be custom. The only config that can be updated automatically would be angular-cli.json, but still is it worth to build such a tool for one configuration ? Ok, maybe there are some more, but still more config files are customized by the devs than not. Other thought. If we still have a tool which will update our configs upon each release and work 99.99% of the time on each angular-cli release. You cant enforce to use it. And the dumb issues with configuration mismatch would not disappear. In my opinion if we agree that we are using angular-cli for complex projects and developers are overriding configs they should take responsibility to keep it up with the new versions. And it is relatively easy, especially after beta, you dont need to change configs upon each release. P.S. As a dev I would not trust a tool which will automatically change all the default configs of angular-cli where I also did various customisations. P.P.S. IMO @angular/cli team is doing great job by backwards supporting older versions of @angular/cli without changing configs that is available for developer. If they keep up with this practice we will have (we already have) a product which will always be compatible with configs that developer can change and the internal configs, like webpack and other that is managed by @angular/cli team. So the team should always keep the balance what developer can change that is not breakable in the future releases and what should be managed internally. |
I got that problem, and can't resolve it since 1.3.2 but I found I use local path to angular/cli After I change it to |
I faced this issue many times recently and always the fix worked for me is :
|
Adding |
rm -rf node_modules |
This worked for me. :) |
Deleting node_modules & package-lock.json, verifying cache, then fresh install worked for me as well. Thanks for the succinct summary, @Sayaren |
Closing as it seems this was a problem with node modules. |
I just got this same problem with the latest version of angular cli today. |
Error:::::::: > Cannot find module 'webpack/lib/node/NodeTemplatePlugin' versions Angular CLI: 1.5.0 @angular/cli: 1.5.0 webpack: error pleasse help how to solve this |
Doing the following steps resolved it for me:
|
We now adopted the following script in our "webpack-setup": "npm i -g webpack webpack-serve webpack-cli webpack-hot-client && npm link webpack webpack-serve webpack-cli webpack-hot-client --save-dev" |
@rvanlaak need to specify versions so that you don't break your app when webpack updates |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
ng build
fails with errorCannot find module 'webpack/lib/node/NodeTemplatePlugin'
after updating tov1.3.0
.The log given by the failure.
Mention any other details that might be useful.
Might be related to #6641.
Installing
webpack
as adevDependency
can be used as a workaround.The text was updated successfully, but these errors were encountered: