无法通过命令行运行Angular 5项目,dev-build命令报错求助
npm run dev-build Error in Your Angular 5 + VS2017 Project Hey there, let's work through this issue step by step! The first and most critical problem I spot is a JSON syntax error in your package.json scripts section, which is almost certainly causing the failure when you run npm run dev-build.
Step 1: Fix the package.json Scripts Syntax
JSON requires commas to separate key-value pairs, but your dev-build entry is missing a trailing comma before the test line. Here's the corrected version:
"scripts": { "dev-build": "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js", "test": "karma start ClientApp/test/karma.conf.js" }
Adding that comma will resolve the initial parsing error that's breaking your command execution.
Step 2: Check for Additional Potential Issues
If fixing the comma doesn't get things working, verify these details next:
- Confirm the webpack config file exists: Double-check that
webpack.config.vendor.jsis located in your project root (or adjust the path in the command if it's stored in a subfolder). - Validate Webpack version compatibility: Angular 5 is designed to work with Webpack 3.x. Run
npm list webpackto check your installed version—if you're using a newer major version (like 4+), there may be breaking changes that require updates to your config file. - Refresh your dependencies: Sometimes cached packages can cause unexpected issues. Run
npm cache clean --forcefollowed bynpm installto refresh your project's dependencies.
After making these tweaks, give npm run dev-build another shot—this should resolve the error if the missing comma was the root cause.
内容的提问来源于stack exchange,提问作者Niranjan

