There have been some problems recently, according to the same package.json, the version after installation is not completely fixed causing the project to fail to start. Take a closer look at the library version numbers in package.json:

The difference between ~ and ^

"Babel - loader", "^ 7.0.0", "body - parser" : "~ 1.15.2"Copy the code

Take version X.Y.Z as an example

X: major version number, when you make an incompatible API change y: minor version number, when you make a backwards compatible functional issue z: revision number, when you make a backwards compatible issue fix ~ X.Y.Z, update to the latest version of Y, such as Body-parser: ~1.15.2, the library will match the latest version of 1.15.z, if 1.16.0 is present, ^ X.Y.Z will not be updated automatically, it will be updated to the latest version of X, such as babel-Loader: ^7.1.1, the library will match the latest version of 7.y.z. If 8.1.1 is present, it will not be updated automaticallyCopy the code

By default, our package.json installation is mostly ^ based, so after running NPM I, some of the packages may have changed. For example:

^ Babel 7.0.0 After installation => The actual version of Babel 7.11.0

npm run dev

Error: Property raw expected type of string but got undefined Failed to start.

2. Troubleshooting process:

I spent a lot of time trying to figure out what was wrong with @babel/core, but I found the babel-plugin-nornj-in-jsx package. I clicked on the error line and found a Babel method called TemplateElement

quasis.push(types.TemplateElement({
  cooked: tagName
}));
Copy the code

Check the documentation for this method in Babel’s 7.11.0:

3. Reason analysis:

@babel/core7.5->@babel/core7.6 has updated the final validation type for mandatory parameters, causing an error:

Before:

After the upgrade:

4. Solutions

Fixed the @babel/core and @babel/types versions to 7.5.0