首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >执行启动脚本失败

执行启动脚本失败
EN

Stack Overflow用户
提问于 2017-11-15 17:46:48
回答 5查看 41.2K关注 0票数 13

角度: 5.0.1 /角CLI: 1.5.0 /节点: 8.9.1 / npm: 5.5.1 / Os: win32 x64

在终端/命令提示符中执行"npm“时,我会得到以下错误。有人能帮我解决这个问题吗?我花了整整一天的时间来修理它,却没有运气。

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

代码语言:javascript
复制
"scripts": {
    "start": "webpack-dev-server --inline --progress --port 8080"
  },

webpack.config.js

代码语言:javascript
复制
module.exports = require('./config/webpack.dev.js');

webpack.common.js

代码语言:javascript
复制
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'
    })
  ]
};

webpack.dev.js

代码语言:javascript
复制
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'
  }
});

webpack.prod.js

代码语言:javascript
复制
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
      }
    })
  ]
});

这里是错误

如果它以ok 1冗长的cli 'C:\Program \nodejs\node.exe结尾,一个详细的cli‘C:\ Files\nodejs\node_modules\npm\bin\npm-cli.js',1详细的cli “启动”2 info使用npm@5.5.1 3 info使用node@v8.9.1 4详细运行脚本'prestart','start',‘启动后’5 info生命周期角-io-示例@1.0.0~预启动:角-io-示例@1.0.0 6信息生命周期角-io-示例@1.0.0~开始:角-io-示例@1.0.0 7详细生命周期角-io-示例@1.0.0~启动:不安全-烫发在生命周期中真正的8长生命周期角-io-示例@1.0.0~开始:路径: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文件\\130\Tools\Binn\C:\Program\Git\cmd;C:\Program(X86)\\130\Tools\Binn\C:\Program(X86)\\130\DTS\Binn\;C:\Program \\130\DTS\Binn\C:\Program\\Client SDK\ODBC\130\Tools\Binn\C:\Program(X86)\\Client SDK\ODBC\130\Tools\Binn\;C:\Program (x86)\Microsoft x86 Files\Microsoft \Dnvm\;C:\Program \Microsoft\Web Platform Installer\;C:\Program \dotnet\C:\Program\nodejs;C:\Program\Microsoft VS Code\bin;C:\ C:\Users\cbonsu\Downloads\sample_pro\webpack \cbonsu\AppData\漫游\npm 9详细的生命周期角-io-示例@1.0.0~start: CWD: CWD 10愚蠢的生命周期角-io示例@1.0.0~start: Args:'/d /s /c',10愚蠢生命周期‘webpack-dev-服务器-内联-进程-端口8080’11愚蠢的生命周期角-io-示例@1.0.0~开始:返回:代码:1信号: null 12 info生命周期角-io-示例@1.0.0~开始:失败执行启动脚本13详细堆栈错误:角-io-示例@1.0.0开始:webpack-dev-server --inline --progress --port 8080 13详细堆栈退出状态1 13 EventEmitter详细堆栈。(C:\ Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16) 13详细堆栈位于emitTwo (events.js:126:13) 13详细堆栈) 在EventEmitter.emit (events.js:214:7) 13详细堆栈在ChildProcess。(C:\ Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13详细堆栈位于emitTwo (events.js:126:13) 13详细堆栈) 在ChildProcess.emit (events.js:214:7) 13详细堆栈在maybeClose (内部/子处理:925: 16 ) 13详细堆栈在Process.ChildProcess._handle.onexit (内部/子程序_process.js:209:5) 14详细的pkgid角-io-例@1.0.0 15详细的cwd C:\Users\cbonsu\Downloads\sample_pro\webpack 16详细的Windows_NT 10.0.15063 17详细的argv "C:\Program \nodejs\节点。exe“C:\Program \nodejs\ node _node\ npm \bin\nm-cli.js”“启动”18详细节点v8.9.1 19详细的npm v5.5.1 20错误代码ELIFECYCLE 21 error errno 1 22 error角io-示例@1.0.0 start:webpack-dev-server --inline --progress --port 8080 22错误退出状态1 23在角-io中失败-示例@1.0.0启动脚本。23错误--这可能不是国家预防机制的问题。上面可能有额外的日志输出。24详细出口1,true

EN

回答 5

Stack Overflow用户

发布于 2017-11-15 19:44:38

它应该会成功的

代码语言:javascript
复制
npm cache clean --force

npm install

npm start 
票数 14
EN

Stack Overflow用户

发布于 2018-10-09 04:36:11

我只是通过验证和清理缓存来解决这个问题,然后将npm更新为最新版本。

代码语言:javascript
复制
npm cache verify
npm install
npm start
票数 2
EN

Stack Overflow用户

发布于 2020-06-27 08:17:53

如果npm clean cache --force npm install npm start不为你工作。尝试重命名根文件夹。这对我来说是件难事。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47314089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档