Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Azure管道构建angular JS应用程序包失败-npm错误!缺少脚本:D:\a\1\s/bundle.js_Angularjs_Azure Devops_Azure Pipelines - Fatal编程技术网

Angularjs Azure管道构建angular JS应用程序包失败-npm错误!缺少脚本:D:\a\1\s/bundle.js

Angularjs Azure管道构建angular JS应用程序包失败-npm错误!缺少脚本:D:\a\1\s/bundle.js,angularjs,azure-devops,azure-pipelines,Angularjs,Azure Devops,Azure Pipelines,因此,我正在尝试构建一个angular.js应用程序,并将其发布到azure blob存储。 我已经完成了项目构建,现在需要运行捆绑任务来创建要发布到blob存储的输出,但是当我运行任务时,我得到了:npm ERR!缺少脚本:D:\a\1\s/bundle.js 所讨论的构建步骤是NPM任务,具有以下YAML: - task: Npm@1 displayName: 'npm bundle' inputs: command: custom workingDir: '

因此,我正在尝试构建一个angular.js应用程序,并将其发布到azure blob存储。 我已经完成了项目构建,现在需要运行捆绑任务来创建要发布到blob存储的输出,但是当我运行任务时,我得到了:npm ERR!缺少脚本:D:\a\1\s/bundle.js

所讨论的构建步骤是NPM任务,具有以下YAML:

    - task: Npm@1
  displayName: 'npm bundle'
  inputs:
    command: custom
    workingDir: '$(System.DefaultWorkingDirectory)'
    verbose: false
    customCommand: 'run $(System.DefaultWorkingDirectory)/bundle.js'
你知道我是怎么打包的吗

以下是任务的输出:

    2021-05-24T18:56:12.9880011Z ##[section]Starting: npm bundle
2021-05-24T18:56:13.0035645Z ==============================================================================
2021-05-24T18:56:13.0036045Z Task         : npm
2021-05-24T18:56:13.0036457Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2021-05-24T18:56:13.0036887Z Version      : 1.182.0
2021-05-24T18:56:13.0037154Z Author       : Microsoft Corporation
2021-05-24T18:56:13.0037500Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
2021-05-24T18:56:13.0038136Z ==============================================================================
2021-05-24T18:56:13.9312661Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.17.0\x64\npm.cmd --version"
2021-05-24T18:56:14.6978076Z 6.14.13
2021-05-24T18:56:16.3055204Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.17.0\x64\npm.cmd config list"
2021-05-24T18:56:17.0914358Z ; cli configs
2021-05-24T18:56:17.0915201Z metrics-registry = "https://registry.npmjs.org/"
2021-05-24T18:56:17.0915747Z scope = ""
2021-05-24T18:56:17.0916249Z user-agent = "npm/6.14.13 node/v14.17.0 win32 x64"
2021-05-24T18:56:17.0916554Z 
2021-05-24T18:56:17.0916973Z ; environment configs
2021-05-24T18:56:17.0917440Z prefix = "C:\\npm\\prefix"
2021-05-24T18:56:17.0917914Z userconfig = "D:\\a\\1\\npm\\642.npmrc"
2021-05-24T18:56:17.0918226Z 
2021-05-24T18:56:17.0918651Z ; globalconfig C:\npm\prefix\etc\npmrc
2021-05-24T18:56:17.0919191Z cache = "C:\\npm\\cache"
2021-05-24T18:56:17.0919472Z 
2021-05-24T18:56:17.0919966Z ; node bin location = C:\hostedtoolcache\windows\node\14.17.0\x64\node.exe
2021-05-24T18:56:17.0920510Z ; cwd = D:\a\1\s
2021-05-24T18:56:17.0920984Z ; HOME = C:\Users\VssAdministrator
2021-05-24T18:56:17.0921466Z ; "npm config ls -l" to show all defaults.
2021-05-24T18:56:17.0921829Z 
2021-05-24T18:56:17.0924582Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.17.0\x64\npm.cmd run bundle.js"
2021-05-24T18:56:17.9822327Z npm ERR! missing script: bundle.js
2021-05-24T18:56:17.9822972Z 
2021-05-24T18:56:17.9823559Z npm ERR! A complete log of this run can be found in:
2021-05-24T18:56:17.9825738Z npm ERR!     C:\npm\cache\_logs\2021-05-24T18_56_17_954Z-debug.log
2021-05-24T18:56:18.0311838Z Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\2021-05-24T18_56_17_954Z-debug.log
2021-05-24T18:56:18.0312533Z 0 info it worked if it ends with ok
2021-05-24T18:56:18.0312918Z 1 verbose cli [
2021-05-24T18:56:18.0313463Z 1 verbose cli   'C:\\hostedtoolcache\\windows\\node\\14.17.0\\x64\\node.exe',
2021-05-24T18:56:18.0314045Z 1 verbose cli   'C:\\hostedtoolcache\\windows\\node\\14.17.0\\x64\\node_modules\\npm\\bin\\npm-cli.js',
2021-05-24T18:56:18.0314505Z 1 verbose cli   'run',
2021-05-24T18:56:18.0314812Z 1 verbose cli   'bundle.js'
2021-05-24T18:56:18.0315127Z 1 verbose cli ]
2021-05-24T18:56:18.0315491Z 2 info using npm@6.14.13
2021-05-24T18:56:18.0315798Z 3 info using node@v14.17.0
2021-05-24T18:56:18.0316183Z 4 verbose stack Error: missing script: bundle.js
2021-05-24T18:56:18.0316777Z 4 verbose stack     at run (C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\lib\run-script.js:155:19)
2021-05-24T18:56:18.0317478Z 4 verbose stack     at C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\lib\run-script.js:63:5
2021-05-24T18:56:18.0318238Z 4 verbose stack     at C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:116:5
2021-05-24T18:56:18.0319056Z 4 verbose stack     at C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:436:5
2021-05-24T18:56:18.0319913Z 4 verbose stack     at checkBinReferences_ (C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:391:45)
2021-05-24T18:56:18.0322803Z 4 verbose stack     at final (C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:434:3)
2021-05-24T18:56:18.0323664Z 4 verbose stack     at then (C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:161:5)
2021-05-24T18:56:18.0324498Z 4 verbose stack     at C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\read-package-json\read-json.js:281:12
2021-05-24T18:56:18.0325369Z 4 verbose stack     at C:\hostedtoolcache\windows\node\14.17.0\x64\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:123:16
2021-05-24T18:56:18.0326349Z 4 verbose stack     at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:73:3)
2021-05-24T18:56:18.0326818Z 5 verbose cwd D:\a\1\s
2021-05-24T18:56:18.0327158Z 6 verbose Windows_NT 10.0.17763
2021-05-24T18:56:18.0327803Z 7 verbose argv "C:\\hostedtoolcache\\windows\\node\\14.17.0\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\14.17.0\\x64\\node_modules\\npm\\bin\\npm-cli.js" "run" "bundle.js"
2021-05-24T18:56:18.0328421Z 8 verbose node v14.17.0
2021-05-24T18:56:18.0328745Z 9 verbose npm  v6.14.13
2021-05-24T18:56:18.0329098Z 10 error missing script: bundle.js
2021-05-24T18:56:18.0329457Z 11 verbose exit [ 1, true ]
2021-05-24T18:56:18.0329605Z 
2021-05-24T18:56:18.0372730Z ##[error]Error: Npm failed with return code: 1
2021-05-24T18:56:18.0394696Z ##[section]Finishing: npm bundle

根据您最近的评论,bundle.js文件是有效的

您可以尝试以下步骤来使用NPM任务运行js文件

  • 在Package.json文件中添加脚本参数
  • 例如:

    {
      "name": "webpackguide",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "webpack-dev-server",
        "bundle":"node bundle.js"
      },
    
    ....
    
    - task: Npm@1
      displayName: 'npm custom'
      inputs:
        command: custom
        workingDir: '$(System.DefaultWorkingDirectory)'
        verbose: false
        customCommand: 'run bundle'
    
  • 在NPM任务中,您可以直接调用bundle命令:
  • 例如:

    {
      "name": "webpackguide",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "webpack-dev-server",
        "bundle":"node bundle.js"
      },
    
    ....
    
    - task: Npm@1
      displayName: 'npm custom'
      inputs:
        command: custom
        workingDir: '$(System.DefaultWorkingDirectory)'
        verbose: false
        customCommand: 'run bundle'
    

    好的,我将任务类型更改为命令行任务,并只调用了node bundle.js:

    steps:
    - script: 'node bundle.js'
      displayName: 'Bundle JS'
    

    混合使用unix/posix样式的路径可能会出现问题。我有一些问题,混合路径分隔符导致gulp失败。打开verbose,查看您期望的命令是否被发送到npm。如果您仍然需要更多帮助,请在此处共享该输出。您的任务配置(减去错误的第一行缩进)看起来通常是正确的。我的赌注在路径上。添加了上面任务的输出。此外,我正在azure中的windows构建代理上运行此功能。应该是unix吗?我不会仅仅为了解决一个小的路径问题而交换环境,但是输出表明您正在下载的源代码的根目录中没有
    bundle.js
    。您能否验证提交是您所期望的,并且文件系统处于您所期望的状态?我想不起来了,但我认为当你手动触发一个构建时,你可以打开
    启用系统诊断
    ,你应该可以读取到所有在job init上克隆的文件。好的,所以我将任务类型改为命令行,并在脚本中运行node bundle.js。看起来它做了一些事情并输出:生成脚本。脚本内容:node bundle.jsHi@evolmonster是否有关于此票证的任何更新?如果这个建议能给你一些帮助,请随时告诉我。只是提醒一下。