npm任务未在Azure管道中创建node_modules文件夹

这不是节点项目,而是MVC Web应用程序。目标是通过Azure管道中的npm步骤来捆绑Quill.js库。

问题:带有所需代码和依赖项的node_modules文件夹未在管道中生成。

package.json配置为仅通过“ npm install”在新位置本地部署解决方案,将重新创建具有所有所需文件和依赖项的node_modules文件夹,以使一切正常运行。

但是,在通过Azure Pipeline任务复制此过程时遇到了麻烦。带有所需内容的node_modules文件夹未创建。做过一些实验,但是下面的顺序对我来说最有意义:

使用NuGet NuGet恢复
VsTest – testAssemblies
使用Node 8.x
npm install(任务设置为在package.json所在的同一项目文件夹中运行)
构建解决方案
其他几项任务……

package.json看起来像这样...

{
  ...,"dependencies": {
    "quill": "^1.3.7"
  }
}

但是node_modules没有像在本地那样创建。

谢谢您的建议。

yfy332189 回答:npm任务未在Azure管道中创建node_modules文件夹

我有一个简单的package.json,我在屏幕下方配置了npm任务。

{
  "name": "service--whoami-sample-app","version": "1.0.0","description": "Azure Functions sample for the Serverless framework","scripts": {
    "test": "echo \"No tests yet...\"","start": "func host start"
  },"keywords": [
    "azure","serverless"
  ],"dependencies": { "quill": "^1.3.7"}
}

enter image description here

我针对自托管代理运行管道。从屏幕截图中,您可以看到已安装了鹅毛笔。

enter image description here

,

找到了解决方案。曾经错误地发现了问题。事实证明,npm实际上是在构建机器上加载了node_modules文件夹,但是构建解决方案并未选择要包含在工件中的文件夹或其内容。

在此博客文章中找到答案

https://blogs.perficient.com/2016/08/11/how-to-add-gulp-output-or-bowernpm-packages-to-webdeploy-package/

解决方案是手动编辑项目文件以添加自定义构建目标,然后将以下内容添加到包含package.json的项目的csproj文件中。

  <Target Name="AddNpmOutput">
    <ItemGroup>
      <_CustomFiles Include="node_modules\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>node_modules\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      AddNpmOutput;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      AddNpmOutput;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>
本文链接:https://www.f2er.com/2728797.html

大家都在问