【问题标题】:Deploying to Azure Linux Web App I get To import Sass files, you first need to install node-sass部署到 Azure Linux Web App 我得到要导入 Sass 文件,首先需要安装 node-sass
【发布时间】:2020-08-23 19:28:11
【问题描述】:

当我将使用 Create-React-App 创建的 React 应用程序部署到 Linux 上的 Azure Web 应用程序时,我在浏览网站时得到以下信息?

要导入 Sass 文件,首先需要安装 node-sass。

当我在本地运行时,一切都很好(从 Mac 运行)。我检查了 DevOps 部署日志,报告它安装了 node-sass 没有问题。我还尝试删除 node_modules 和 npm install 中的 node-sass 文件夹。这再次添加了 node-sass 没有问题,但我仍然收到错误?

有没有人遇到过这个问题或者有什么建议?

这是 Yaml 文件。

# Node.js React Web App to Linux on Azure
# Build a Node.js React app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

variables:

  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: '<Remove for Security>'

  # Web app name
  webAppName: '<Remove for Security>'

  # Environment name
  environmentName: '<Remove for Security>'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool: 
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:            
          - task: AzureRmWebAppDeployment@4
            displayName: 'Azure App Service Deploy: <Remove for Security>'
            inputs:
              azureSubscription: $(azureSubscription)
              appType: webAppLinux
              WebAppName: $(webAppName)
              packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              RuntimeStack: 'NODE|10.10'
              StartupCommand: 'npm run start'
              ScriptType: 'Inline Script'
              InlineScript: |
                npm install
                npm run build --if-present

【问题讨论】:

  • 你能展示你的管道吗?
  • @KrzysztofMadej - 我已经上传了 Yaml 文件

标签: reactjs azure-devops azure-web-app-service node-sass


【解决方案1】:

我在另一个节点包中遇到了类似的问题。在节点包无法解决的这种情况下,请尝试使用 -g 标志全局安装您的节点包。

【讨论】:

  • 由于权限问题,我无法在 Linux Azure Web App 中执行此操作。
  • 您通过共享的 yaml 文件安装。我看到您正在管道中的部署阶段执行内联 npm install 命令。将带有全局标志的安装命令放在那里。
  • 最后我在 VSCode 中使用了 Live Sass 编译器,并将每个 React 组件链接到所需的组件 CSS 文件。
猜你喜欢
  • 2020-03-05
  • 1970-01-01
  • 2023-04-08
  • 2014-11-09
  • 2016-07-09
  • 2018-05-05
  • 2018-10-17
  • 2021-11-05
  • 2014-02-27
相关资源
最近更新 更多