fly deploy is throwing 401 Incorrect or missing password.

Hi, I am trying to deploy node.js application with Nest.js framework and deployment(fly deploy) is throwing an 401 error. I even tried to log in to npm but it didn’t help, still got same error. I didn’t find any way how to fix this. Is there anybody who can help me? Thanks a lot!

screenshot of full log:

generated dockerfile:

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.12.1
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="NestJS"

# NestJS app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install -y build-essential pkg-config python

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .

# Build application
RUN npm run build


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]

generated fly.toml

# fly.toml app configuration file generated for skialpp on 2023-11-06T00:25:01+01:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "skialpp"
primary_region = "ams"

[build]

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

up

Can you post your package.json file?

Hi, thanks for the answer, below you can see my whole package.json

{
  "name": "api",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/common": "^9.0.0",
    "@nestjs/core": "^9.0.0",
    "@nestjs/mongoose": "^10.0.1",
    "@nestjs/passport": "^10.0.2",
    "@nestjs/platform-express": "^9.0.0",
    "@types/bcrypt": "^5.0.1",
    "@types/express-session": "^1.17.9",
    "bcrypt": "^5.1.1",
    "express-session": "^1.17.3",
    "mongoose": "^7.6.4",
    "passport": "^0.6.0",
    "passport-local": "^1.0.0",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0"
  },
  "devDependencies": {
    "@flydotio/dockerfile": "^0.4.10",
    "@nestjs/cli": "^9.0.0",
    "@nestjs/schematics": "^9.0.0",
    "@nestjs/testing": "^9.0.0",
    "@types/express": "^4.17.13",
    "@types/jest": "28.1.8",
    "@types/node": "^16.0.0",
    "@types/passport-local": "^1.0.37",
    "@types/supertest": "^2.0.11",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "eslint": "^8.0.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "jest": "28.1.3",
    "prettier": "^2.3.2",
    "source-map-support": "^0.5.20",
    "supertest": "^6.1.3",
    "ts-jest": "28.0.8",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig-paths": "4.1.0",
    "typescript": "^4.7.4"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

I can install those packages without a password. The next place to look is package-lock.json. Try modifying your Dockerfile:

COPY --link package.json ./
RUN npm install --include=dev

I’m not suggesting this as a permanent fix, but rather as a way of determining where the problem is. Should this work, the next thing to try is to delete package-lock.json locally, run npm install locally to regenerate it and restore the Dockerfile to its original state.

Resolved. After examining package-lock.json I found out I am using my company’s private npm config. Thanks a lot!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.