Webpack beginners to trample the pit to remember

Source: Internet
Author: User
Tags npm scripts

Precautions: 1. Webpack do not install in the global environment, in which project to use, it is installed under the project can

1. Question one: After NPM init Initializes a project, add the Webpack.config.js file and install the NPM package under the project with NPM install Webpack--save-dev,

Then execute the webpack command at the root of the project to report the following error

Cause: Although Webpack is installed in the project, execution of webpack execution at the root of the project is still global Webpack the error is due to the fact that Webpack is not installed globally. 、

Solution: Wrap the Webpack "start" in the script script in Pacage.json: "Webpack" and then execute NPM run start at the root of the project.

Question: Why does it have to be in NPM scripts to use the local Package command?

1. The Webpack in the project is not global, so it is not possible to execute the Webpack.

The NPM Start command in 2.NPM script first finds the Webpack package in this project, executes it, finds it, and continues to find it, and so on.

3. It's a good idea to use NPM script to wrap node's CLI

Webpack beginners to trample the pit to remember

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.