执行启动脚本失败

use*_*229 13 npm webpack angular

Angular: 5.0.1 / Angular CLI: 1.5.0 / Node: 8.9.1 / npm: 5.5.1 / Os: win32 x64

在终端/命令提示符中执行“npm start”时出现以下错误。谁能帮我解决这个问题?我花了一整天的时间试图修复它,但没有运气。

这是我的 package.json 的脚本部分

"scripts": {
    "start": "webpack-dev-server --inline --progress --port 8080"
  },
Run Code Online (Sandbox Code Playgroud)

webpack.config.js

module.exports = require('./config/webpack.dev.js');
Run Code Online (Sandbox Code Playgroud)

webpack.common.js

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');

module.exports = {
  entry: {
    'polyfills': './src/polyfills.ts',
    'vendor': './src/vendor.ts',
    'app': './src/main.ts'
  },

  resolve: {
    extensions: ['.ts', '.js']
  },

  module: {
    rules: [
      {
        test: /\.ts$/,
        loaders: [
          {
            loader: 'awesome-typescript-loader',
            options: { configFileName: helpers.root('src', 'tsconfig.json') }
          } , 'angular2-template-loader'
        ]
      },
      {
        test: /\.html$/,
        loader: 'html-loader'
      },
      {
        test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
        loader: 'file-loader?name=assets/[name].[hash].[ext]'
      },
      {
        test: /\.css$/,
        exclude: helpers.root('src', 'app'),
        loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
      },
      {
        test: /\.css$/,
        include: helpers.root('src', 'app'),
        loader: 'raw-loader'
      }
    ]
  },

  plugins: [
    // Workaround for angular/angular#11580
    new webpack.ContextReplacementPlugin(
      // The (\\|\/) piece accounts for path separators in *nix and Windows
      /angular(\\|\/)core(\\|\/)@angular/,
      helpers.root('./src'), // location of your src
      {} // a map of your routes
    ),

    new webpack.optimize.CommonsChunkPlugin({
      name: ['app', 'vendor', 'polyfills']
    }),

    new HtmlWebpackPlugin({
      template: 'src/index.html'
    })
  ]
};
Run Code Online (Sandbox Code Playgroud)

webpack.dev.js

var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');

module.exports = webpackMerge(commonConfig, {
  devtool: 'cheap-module-eval-source-map',

  output: {
    path: helpers.root('dist'),
    publicPath: '/',
    filename: '[name].js',
    chunkFilename: '[id].chunk.js'
  },

  plugins: [
    new ExtractTextPlugin('[name].css')
  ],

  devServer: {
    historyApiFallback: true,
    stats: 'minimal'
  }
});
Run Code Online (Sandbox Code Playgroud)

webpack.prod.js

var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');

const ENV = process.env.NODE_ENV = process.env.ENV = 'production';

module.exports = webpackMerge(commonConfig, {
  devtool: 'source-map',

  output: {
    path: helpers.root('dist'),
    publicPath: '/',
    filename: '[name].[hash].js',
    chunkFilename: '[id].[hash].chunk.js'
  },

  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
      mangle: {
        keep_fnames: true
      }
    }),
    new ExtractTextPlugin('[name].[hash].css'),
    new webpack.DefinePlugin({
      'process.env': {
        'ENV': JSON.stringify(ENV)
      }
    }),
    new webpack.LoaderOptionsPlugin({
      htmlLoader: {
        minimize: false // workaround for ng2
      }
    })
  ]
});
Run Code Online (Sandbox Code Playgroud)

这是错误

0 信息,如果它以 ok 结尾,它就可以工作 1 详细 cli ['C:\Program Files\nodejs\node.exe', 1 详细 cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js ', 1 个详细的 cli
'start' ] 2 条信息使用 npm@5.5.1 3 条信息使用 node@v8.9.1 4 详细运行脚本 [ 'prestart', 'start', 'poststart' ] 5 条信息生命周期 angular-io-example@1.0.0 ~prestart: angular-io-example@1.0.0 6 info 生命周期 angular-io-example@1.0.0~start: angular-io-example@1.0.0 7 详细生命周期 angular-io-example@1.0.0~start :生命周期中的 unsafe-perm true 8 详细生命周期 angular-io-example@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\cbonsu \Downloads\sample_pro\webpack\node_modules.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\ 130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn \ManagementStudio\;C:\WINDOWS\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\ dotnet\;C:\Program Files\nodejs\;C:\Users\cbonsu\AppData\Local\Microsoft\WindowsApps;C:\Program Files\nodejs;C:\Program Files\Microsoft VS Code\bin;C:\ Users\cbonsu\AppData\Roaming\npm 9 详细生命周期 angular-io-example@1.0.0~start: CWD: C:\Users\cbonsu\Downloads\sample_pro\webpack 10 愚蠢的生命周期 angular-io-example@1.0.0 ~开始:参数:[ '/d /s /c', 10 愚蠢的生命周期 'webpack-dev-server --inline --progress --port 8080' ] 11 愚蠢的生命周期 angular-io-example@1.0.0~start:返回:代码: 1 信号:空 12 信息生命周期 angular-io-example@1.0.0~start:无法执行启动脚本 13 详细堆栈错误:angular-io-example@1.0.0 启动: webpack-dev-server --inline --progress --port 808013 详细堆栈退出状态 1 13 在 EventEmitter 的详细堆栈。(C:\ Program Files文件\的NodeJS \ node_modules \ NPM \ node_modules \ NPM-生命周期\ index.js:280:16)13详细的堆栈在emitTwo(events.js:126:13)13详细的堆栈 在ChildProcess.emit(事件... io-example@1.0.0 15 详细 cwd C:\Users\cbonsu\Downloads\sample_pro\webpack 16 详细 Windows_NT 10.0.15063 17 详细 argv "C:\Program Files\nodejs\node.exe" "C:\Program Files \nodejs\node_modules\npm\bin\npm-cli.js" "start" 18 详细节点 v8.9.1 19 详细 npm v5.5。
在EventEmitter.emit(事件.js:214:7) ChildProcess 中的 13 个详细堆栈。(C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 详细堆栈在emitTwo (events.js:126:13) 13 详细堆栈
webpack-dev-server --inline --progress --port 808022 错误退出状态 1 23 错误 angular-io-example@1.0.0 启动脚本失败。23 错误 这可能不是 npm 的问题。上面可能有额外的日志输出。24 详细退出 [ 1, true ]

Fat*_*med 12

它应该做到

npm cache clean --force

npm install

npm start 
Run Code Online (Sandbox Code Playgroud)

  • 不,我没有先删除 node_modules ......我现在已经删除了 node_modules 并重新运行命令“npm clean cache --force”、“npm install”,最后是“npm start”。问题仍然存在。 (2认同)