npm install is taking (30+) minutes in server which runs on debian 9.8.
I want to know what might cause this?
I've already tried npm set progress=false and npm config set registry http://registry.npmjs.org/ but none of it helped.
I'm running it in docker container.
this is my package.json
{
"name": "name",
"version": "1.0.0",
"main": "server/server.js",
"engines": {
"node": ">=6"
},
"scripts": {
"lint": "eslint .",
"start": "nodemon .",
"client": "cd client && npm start",
"test": "mocha"
},
"dependencies": {
"babel-eslint": "^10.0.1",
"compression": "^1.0.3",
"cors": "^2.5.2",
"eslint-config-react-app": "^4.0.0",
"eslint-plugin-flowtype": "^3.7.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"express-jwt": "^5.3.1",
"express-winston": "^3.2.0",
"helmet": "^3.10.0",
"html-element": "^2.3.0",
"jwks-rsa": "^1.5.1",
"libxmljs": "^0.19.5",
"loopback": "^3.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^6.2.0",
"loopback-connector-mongodb": "^4.2.0",
"loopback-connector-rest": "^3.4.1",
"node": "8.16.0",
"node-blockly": "^1.0.36",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^3.0.0",
"winston": "^3.2.1"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^3.17.1",
"eslint-config-loopback": "^8.0.0",
"loopback-supertest-models": "^3.5.0",
"mocha": "^6.1.4",
"nodemon": "^1.19.0",
"supertest": "^4.0.2"
},
"repository": {
"type": "",
"url": ""
},
"license": "UNLICENSED",
"description": "description"
}
and this is my Dockerfile
FROM node:10.9.0-alpine as builder
RUN mkdir -p /app/server
WORKDIR /app/server
COPY package*.json /app/server/
#COPY yarn* /app/server/
# Disables npm progress bar
RUN npm set progress=false
# Set npm registry to http://registry.npmjs.org
RUN npm config set registry http://registry.npmjs.org/
#! Install the build requirements for bcrypt
RUN apk update && apk upgrade \
&& apk --no-cache add --virtual git builds-deps build-base \
&& apk --no-cache add make gcc g++ python \
&& npm install --save node-gyp node-pre-gyp \
&& rm -rf /var/cache/apk/*
# && yarn add node-gyp node-pre-gyp
# Install dependencies
# RUN yarn install --production=true
RUN npm install --production
# Copy the server files over
COPY . /app/server/
RUN apk del make gcc g++ python
FROM node:10.9.0-alpine
# Create and set the working directory
RUN mkdir -p /app/server
WORKDIR /app/server
# Copy the server from the build container
COPY --from=builder /app/server /app/server
CMD ["node", "."]
Related
I'm trying to deploy my Sveltekit App in Railway
Whenever I try to run
docker run --publish 8000:8000 my_project
I get back
> my-project#0.0.1 build
> vite build
sh: vite: not found
This is my dockerfile
# syntax=docker/dockerfile:1
FROM node:19.4.0-alpine3.16
ENV NODE_ENV=production
WORKDIR /app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install
RUN npm install dotenv
RUN npm install #directus/sdk
RUN npm install vite
COPY . .
CMD [ "npm", "run", "build" ]
This is my package.json file
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"test": "playwright test",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"dependencies": {
"#directus/sdk": "^10.3.1",
"dotenv": "^16.0.3"
}
}
Script and dependencies above
The devDependencies are the following, at least the ones I found competent
"devDependencies": {
"#sveltejs/adapter-auto": "^1.0.0",
"#sveltejs/kit": "^1.0.0",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"vite": "^4.0.0",
"vitest": "^0.25.3"
},
I'm trying to create a local env with docker for a nuxtjs project.
This is my docker-compose.yml:
version: '3.3'
services:
frontend:
container_name: frontend
restart: unless-stopped
working_dir: /app
build:
dockerfile: Dockerfile
volumes:
- ./application:/app
ports:
- "3001:3000"
environment:
HOST: 0.0.0.0
command: npm run dev
This is my Dockerfile
FROM alpine:3.15
RUN apk update
RUN apk add --no-cache --update make
RUN apk add --no-cache --update python3 py3-pip
RUN apk add --no-cache --update nodejs npm
RUN apk add --no-cache --update g++
WORKDIR /app
COPY application /app
RUN npm install -g nuxt
RUN NODE_ENV=development npm install
RUN npm install
ENV HOST 0.0.0.0
EXPOSE 3001
When I run docker-compose up --build
✖ Nuxt Fatal Error Error: Cannot find module '#nuxtjs/eslint-module'
Require stack:
/usr/local/lib/node_modules/nuxt/node_modules/#nuxt/core/dist/core.js
This is my package.json
{
"name": "demo",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "npm run lint:js",
"lintfix": "npm run lint:js -- --fix",
"lintreport": "npm run lint:js -- -f node_modules/eslint-html-reporter/reporter.js -o eslint-report.html",
"test": "jest"
},
"dependencies": {
"#nuxtjs/auth-next": "5.0.0-1637745161.ea53f98",
"#nuxtjs/axios": "^5.13.6",
"#nuxtjs/sitemap": "^2.4.0",
"axios": "^0.24.0",
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"webpack": "^4.46.0"
},
"devDependencies": {
"#babel/eslint-parser": "^7.16.3",
"#nuxt/test-utils": "^0.2.2",
"#nuxtjs/eslint-config": "^8.0.0",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/google-fonts": "^1.3.0",
"#nuxtjs/tailwindcss": "^4.2.1",
"#vue/test-utils": "^1.3.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^27.4.4",
"eslint": "^8.4.1",
"eslint-html-reporter": "^0.7.4",
"eslint-plugin-nuxt": "^3.1.0",
"eslint-plugin-vue": "^8.2.0",
"express": "^4.17.2",
"jest": "^27.4.5",
"postcss": "^8.4.4",
"supertest": "^6.1.6",
"vue-jest": "^3.0.4"
}
}
Looks like that the devDependencies are not installed.
Any idea how to run the prject?
You can use this hack to avoid mounting your node_modules and overriding the ones in the container.
volumes:
- ./application:/app
- /app/node_modules
ref: Docker-compose: node_modules not present in a volume after npm install succeeds
I try to run the application in Docker, with the installation of dependencies, from a private repository, but I get this error.
Start docker container docker run -p 3000:80
module.js:550
throw err;
^
Error: Cannot find module 'debug'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/src/server.js:5:13)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
my Dockerfile
install using YARN
FROM node:8
ENV YARN_VERSION 1.16.0
ARG SSH_PRIVATE_KEY
RUN mkdir -p /root/.ssh
RUN echo $SSH_PRIVATE_KEY > /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa
RUN ssh-keyscan -H bitbucket.org >> /etc/ssh/ssh_known_hosts
RUN curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz
COPY package*.json ./
COPY . .
EXPOSE 3000
CMD [ "node", "server.js" ]
package.json
{
"name": "test-home-nodejs",
"description": "",
"version": "1.17.2",
"author": "",
"scripts": {
"start": "node server.js",
"test": "NODE_ENV=test node node_modules/mocha/bin/mocha --recursive -R mocha-bamboo-reporter",
"watchTests": "NODE_ENV=test ./node_modules/gulp/bin/gulp.js watch-pot"
},
"repository": {
"type": "git",
"url": "git#bitbucket.org:igorbell/test-home.git"
},
"dependencies": {
"async": "^1.1.0",
"autosize": "^4.0.0",
"babel-core": "^6.25.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babelify": "^7.3.0",
"bluebird": "^3.0.0",
"body-parser": "^1.9.0",
"bower": "^1.3.3",
"browserify": "^13.0.1",
"browserify-shim": "^3.8.11",
"chalk": "^1.1.0",
"chosen-js": "^1.7.0",
"client-sessions": "^0.7.0",
"cloudinary": "~1.9.0",
"coffeeify": "2.0.1",
"compression": "^1.4.3",
configured according to this instruction
enter link description here
When using the NMP, there was almost the same error
UPDATE in dockerfile
ARG NODE_ENV=qa
ENV NODE_ENV=${NODE_ENV}
Despite trying everything I know how to do and doing a ton of searching I cannot figure out what is wrong. I am trying to launch an older project in docker. The package.json file is set to install gulp#3.9.1 but when the Dockerbuild runs and installs the packages it installs 4.0.2 every time.
How can I get my docker image to install the correct version of gulp?
Dockerfile
WORKDIR /var/www
#Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt update
RUN apt install -y nodejs lsof
#Install NPM deps
COPY ./package-lock.json /var/www/package-lock.json
COPY ./package.json /var/www/package.json
RUN npm install --quiet >> /dev/null \
&& npm link gulp \
&& gulp -v
package.json
"devDependencies": {
"gulp": "^3.9.1",
}
package-lock.json
"gulp": {
"version": "3.9.1",
"resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz",
"integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=",
"dev": true,
"requires": {
"archy": "^1.0.0",
"chalk": "^1.0.0",
"deprecated": "^0.0.1",
"gulp-util": "^3.0.0",
"interpret": "^1.0.0",
"liftoff": "^2.1.0",
"minimist": "^1.1.0",
"orchestrator": "^0.3.0",
"pretty-hrtime": "^1.0.0",
"semver": "^4.1.0",
"tildify": "^1.0.0",
"v8flags": "^2.0.2",
"vinyl-fs": "^0.3.0"
},
"dependencies": {
"semver": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz",
"integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=",
"dev": true
}
}
},
Docker Build output
Step 12/20 : RUN npm install --quiet >> /dev/null && npm link gulp && gulp -v
---> Running in 8dc99b37ab8a
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/gulp/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ gulp#4.0.2
added 314 packages from 217 contributors in 16.348s
/var/www/node_modules/gulp -> /usr/lib/node_modules/gulp
CLI version: 2.2.0
Local version: 4.0.2
I have this package.json:
{
"name": "lahmacun",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"lint": "standard --verbose | snazzy",
"lintdiff": "git diff --name-only --cached --relative | grep '\\.js$' | xargs standard | snazzy",
"fixcode": "standard --fix",
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean",
"clean:android": "cd android/ && ./gradlew clean && cd .. && react-native run-android",
"newclear": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build && rm -rf node_modules/ && npm cache clean && npm i",
"test": "ava",
"test:watch": "ava --watch",
"coverage": "nyc ava && nyc report --reporter=html && open coverage/index.html || xdg-open coverage/index.html",
"android:build": "cd android && ./gradlew assembleRelease",
"android:install": "cd android && ./gradlew assembleRelease && ./gradlew installRelease",
"android:hockeyapp": "cd android && ./gradlew assembleRelease && puck -submit=auto app/build/outputs/apk/app-release.apk",
"android:devices": "$ANDROID_HOME/platform-tools/adb devices",
"android:logcat": "$ANDROID_HOME/platform-tools/adb logcat *:S ReactNative:V ReactNativeJS:V",
"android:shake": "$ANDROID_HOME/platform-tools/adb devices | grep '\\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} $ANDROID_HOME/platform-tools/adb -s {} shell input keyevent 82",
"precommit": "npm run git-hook",
"prepush": "npm run git-hook",
"git-hook": "npm run lint -s && npm test -s"
},
"dependencies": {
"apisauce": "^0.10.0",
"format-json": "^1.0.3",
"lodash": "^4.17.2",
"querystringify": "0.0.4",
"ramda": "^0.23.0",
"react": "15.4.2",
"react-native": "0.42.0",
"react-native-animatable": "^1.1.0",
"react-native-config": "^0.2.1",
"react-native-device-info": "^0.10.0",
"react-native-drawer": "^2.3.0",
"react-native-i18n": "^1.0.0",
"react-native-router-flux": "^3.37.0",
"react-native-vector-icons": "^4.0.0",
"react-navigation": "^1.0.0-beta.6",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"redux-persist": "^4.1.0",
"redux-saga": "^0.14.3",
"reduxsauce": "0.4.1",
"seamless-immutable": "^7.0.1"
},
"devDependencies": {
"ava": "^0.18.2",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.18.0",
"enzyme": "^2.6.0",
"husky": "^0.13.1",
"ignite-animatable": "^0.3.1",
"ignite-dev-screens": "^2.0.0-beta.1",
"ignite-i18n": "^0.1.1",
"ignite-ir-boilerplate-2016": "^0.2.0",
"ignite-vector-icons": "^0.2.1",
"mockery": "^2.0.0",
"nyc": "^10.1.2",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.4.0",
"react-native-mock": "^0.3.1",
"reactotron-apisauce": "^1.7.0",
"reactotron-react-native": "^1.7.0",
"reactotron-redux": "^1.7.0",
"reactotron-redux-saga": "^1.7.0",
"snazzy": "^6.0.0",
"standard": "8.6.0"
},
"ava": {
"files": [
"Tests/**/*.js",
"!Tests/Setup.js"
],
"require": [
"babel-register",
"babel-polyfill",
"react-native-mock/mock",
"./Tests/Setup"
],
"babel": "inherit"
},
"standard": {
"parser": "babel-eslint",
"globals": [
"describe",
"it",
"fetch",
"navigator",
"__DEV__",
"XMLHttpRequest",
"FormData",
"React$Element"
]
},
"config": {
"ghooks": {
"pre-commit": "if [ -d 'ignite-base' ]; then cd ignite-base; fi; npm run lint"
}
}
}
And when I run following command locally, it works absolutely fine.
lint --xml test.xml *
But in Jenkins after npm install in the shell script, I get this error after the errors have been displayed successfully:
03:56:48 ✖ 115484 problems
03:56:48
03:56:48 npm ERR! Linux 4.4.0-62-generic
03:56:48 npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "lint" "__tests__" "android" "app.json" "components" "data.js" "images" "index.android.js" "index.ios.js" "ios" "node_modules" "package.json" "react-native-packager-cache-4d9c2999" "reports" "yarn.lock"
03:56:48 npm ERR! node v7.7.2
03:56:48 npm ERR! npm v4.1.2
03:56:48 npm ERR! code ELIFECYCLE
03:56:48 npm ERR! MyTest1#0.0.1 lint: `standard --verbose | snazzy "__tests__" "android" "app.json" "components" "data.js" "images" "index.android.js" "index.ios.js" "ios" "node_modules" "package.json" "react-native-packager-cache-4d9c2999" "reports" "yarn.lock"`
03:56:48 npm ERR! Exit status 1
03:56:48 npm ERR!
03:56:48 npm ERR! Failed at the MyTest1#0.0.1 lint script 'standard --verbose | snazzy "__tests__" "android" "app.json" "components" "data.js" "images" "index.android.js" "index.ios.js" "ios" "node_modules" "package.json" "react-native-packager-cache-4d9c2999" "reports" "yarn.lock"'.
03:56:48 npm ERR! Make sure you have the latest version of node.js and npm installed.
03:56:48 npm ERR! If you do, this is most likely a problem with the MyTest1 package,
03:56:48 npm ERR! not with npm itself.
03:56:48 npm ERR! Tell the author that this fails on your system:
03:56:48 npm ERR! standard --verbose | snazzy "__tests__" "android" "app.json" "components" "data.js" "images" "index.android.js" "index.ios.js" "ios" "node_modules" "package.json" "react-native-packager-cache-4d9c2999" "reports" "yarn.lock"
03:56:48 npm ERR! You can get information on how to open an issue for this project with:
03:56:48 npm ERR! npm bugs MyTest1
03:56:48 npm ERR! Or if that isn't available, you can get their info via:
03:56:48 npm ERR! npm owner ls MyTest1
03:56:48 npm ERR! There is likely additional logging output above.
03:56:48
03:56:48 npm ERR! Please include the following file with any support request:
03:56:48 npm ERR! /root/.jenkins/jobs/smayle/workspace/npm-debug.log
03:56:48 Build step 'Execute shell' marked build as failure
03:56:48 Finished: FAILURE
All I am doing in Jenkins in the shell script is this:
npm install
npm run lint *