0

I have a project that builds locally, and I try to create a Docker image. In my project, I install NPM packages, and my package file is located at: \src\Core.Blazor\package.json

But, when I try to build my Docker image, it failed with the following error:

npm ERR! code ENOLOCAL
npm ERR! Could not install "src/Core.Blazor/package.json" as it is not a directory and is not a file with a name ending in .tgz, .tar.gz or .tar

I join the Dockerfile too:

### >>> GLOBALS
ARG ENVIRONMENT="Production"
ARG PROJECT="PyProd.IdentityServer.Host"
### <<<

# debian buster - AMD64
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build

### >>> IMPORTS
ARG ENVIRONMENT
ARG PROJECT
### <<<

ARG NUGET_CACHE=https://api.nuget.org/v3/index.json
ARG NUGET_FEED=https://api.nuget.org/v3/index.json

# Copy sources
COPY src/ /app/src
ADD common.props /app

WORKDIR /app

# Installs NodeJS to build typescripts
RUN apt-get update
RUN apt-get install curl
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
RUN npm install /app/src/Core.Blazor/package.json

After trying to fix with the following, I also get an error:

RUN npm install /app/src/SmartPixel.Core.Blazor/

Here is the error I got:

> aspnet-parcel-exp@0.1.0 build /app/src/SmartPixel.Core.Blazor
  > parcel build wwwroot/assets/blazorcore.js --out-dir wwwroot/dist/
  
  sh: 1: parcel: not found
  npm ERR! code ELIFECYCLE
  npm ERR! syscall spawn
  npm ERR! file sh
  npm ERR! errno ENOENT
  npm ERR! aspnet-parcel-exp@0.1.0 build: `parcel build wwwroot/assets/blazorcore.js --out-dir wwwroot/dist/`
  npm ERR! spawn ENOENT
  npm ERR! 
  npm ERR! Failed at the aspnet-parcel-exp@0.1.0 build script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  npm WARN Local package.json exists, but node_modules missing, did you mean to install?

I also join the package.json file:

{
  "name": "aspnet-parcel-exp",
  "private": true,
  "version": "0.1.0",
  "devDependencies": {
    "parcel": "1.12.3"
  },
  "includePaths": [
    "./wwwroot/assets/js",
    "./wwwroot/assets/css"
  ],
  "scripts": {
    "build": "parcel build wwwroot/assets/blazorcore.js --out-dir wwwroot/dist/",
    "watch": "parcel watch wwwroot/assets/blazorcore.js --out-dir wwwroot/dist/"
  }
}
ClubberLang
  • 1,624
  • 3
  • 21
  • 45

1 Answers1

0

I don't know NodeJS, but as your error says:

npm ERR! Could not install "src/Core.Blazor/package.json" as it is not a directory and is not a file with a name ending in .tgz, .tar.gz or .tar

I believe you should change your Dockerfile to this:

RUN npm install /app/src/Core.Blazor/

Or even this:

RUN npm install /app/src/Core.Blazor

As the second one doesn't have trailing slash.

Saeed
  • 3,255
  • 4
  • 17
  • 36
  • Thanks. I have try but as I also explained briefly I got another error. I have updated the description with more details. – ClubberLang Mar 11 '21 at 20:34
  • I'm afraid I'm not NodeJS developer. It seems there's something wrong with your codes, not docker. – Saeed Mar 11 '21 at 20:49