I was able to install all packages with npm, but two days ago I'm getting this error.
Step 8/12 : RUN npm install
---> Running in aedc04c5281e
> sharp#0.25.4 install /home/project/website/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linuxmusl-x64.tar.gz
> cwebp-bin#5.1.0 postinstall /home/project/website/node_modules/cwebp-bin
> node lib/install.js
⚠ spawn /home/project/website/node_modules/cwebp-bin/vendor/cwebp ENOENT
⚠ cwebp pre-build test failed
ℹ compiling from source
...
Here is my docker file
FROM node:12-alpine
RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
RUN mkdir -p /home/project/website/node_modules && chown -R node:node /home/project/website
WORKDIR /home/project/website
COPY /package*.json ./
USER node
RUN npm cache verify
RUN npm install
COPY --chown=node:node . .
RUN chmod +x wait-for.sh
RUN chmod -R 0755 /home/project/website/src/views/
EXPOSE 8080
after the building completed I get this in logs
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '/home/project/website/node_modules/.bin/nodemon'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
and after I run this following cmd
docker-compose run website sh -c "npm list --depth=0"
I get this
+-- UNMET DEPENDENCY bcryptjs#2.4.3
+-- UNMET DEPENDENCY compression#1.7.4
| +-- accepts#1.3.7
| +-- bytes#3.0.0
| +-- compressible#2.0.18
| +-- debug#2.6.9
| +-- on-headers#1.0.2
| +-- safe-buffer#5.1.2
| `-- vary#1.1.2
+-- UNMET DEPENDENCY cors#2.8.5
| +-- object-assign#4.1.1
| `-- vary#1.1.2
+-- UNMET DEPENDENCY dateformat#3.0.3
+-- UNMET DEPENDENCY dotenv#8.2.0
+-- UNMET DEPENDENCY ejs#3.1.5
| `-- jake#10.8.2
+-- UNMET DEPENDENCY express#4.17.1
...
and my packages are
{
"name": "website",
"version": "0.0.0",
"main": "app.js",
"scripts": {
"start": "nodemon src/app.js"
},
"author": "Noah Lc",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"compression": "^1.7.4",
"cors": "^2.8.5",
"dateformat": "^3.0.3",
"dotenv": "^8.2.0",
"ejs": "^3.1.3",
"express": "^4.17.1",
"fs": "0.0.1-security",
"helmet": "^4.1.1",
"image-size": "^0.8.3",
"imagemin": "^7.0.1",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-webp": "^6.0.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.7.7",
"multer": "^1.4.2",
"nodemailer": "^6.4.11",
"nodemon": "^2.0.3",
"sharp": "^0.25.4",
"sitemap": "^6.2.0",
"slugify": "^1.4.0",
"superagent": "^5.2.2",
"validator": "^12.0.0",
"winston": "^3.3.3"
},
"devDependencies": {}
}
Are there any clean ways to skip pre and post-build steps of those dips in the plugin itself to avoid any issues in the containerized environment?
RUN apk add --no-cache \
--update \
build-base \
mesa-dev \
gcc \
autoconf \
automake \
libtool \
zlib-dev \
nasm \
mesa \
libxi \
libpng-dev \
libjpeg \
jpeg-dev
Related
I've been trying to debug this super weird issue. Got a project where I am trying to install a private repository with the npm command.
This does not work when it's in an existing project but does when it's a newly created project that's just been created with npm init.
The existing project is in /app and the new project is in /opt (for testing purposes)
Running npm add git+ssh://git#github.com:company/repository.git in /app returns with:
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git#github.com/company/repository.git
npm ERR! git#github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-11-24T00_25_10_559Z-debug.log
Running the exact same command from the /opt project installs the package correctly without any issues.
I'm running this from an alpine docker box with openssh installed.
This is the Dockerfile
FROM node:16.13-alpine
RUN apk add --no-cache openssh-client git python2
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts && ln -s /run/secrets/ssh_key ~/.ssh/id_rsa && ln -s /run/secrets/ssh_pub_key ~/.ssh/id_rsa.pub
RUN mkdir /app
WORKDIR /app
A few more informative stuff
/app # node -v
v16.13.0
/app # npm -v
8.1.4
/app # ssh -T git#github.com
Hi AzaZPPL! You've successfully authenticated, but GitHub does not provide shell access.
package.json
{
"name": "project",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"generate-schema": "node apollo/generate-schema.js",
"lint": "eslint --ext .js,.vue --ignore-path .eslintignore .",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .eslintignore ."
},
"dependencies": {
"#nuxtjs/apollo": "^4.0.1-rc.4",
"#nuxtjs/auth": "^4.9.1",
"#nuxtjs/axios": "^5.12.2",
"#nuxtjs/dayjs": "^1.2.1",
"#nuxtjs/style-resources": "^1.0.0",
"apollo-cache-inmemory": "^1.6.6",
"copy-to-clipboard": "^3.3.1",
"core-js": "^3.6.5",
"date-fns": "^2.19.0",
"dotenv": "^8.2.0",
"filepond": "^4.27.1",
"filepond-plugin-file-validate-type": "^1.2.6",
"filepond-plugin-image-preview": "^4.6.6",
"graphql-tag": "^2.11.0",
"js-file-download": "^0.4.12",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.20",
"nuxt": "^2.14.6",
"nuxt-buefy": "^0.4.10",
"nuxt-i18n": "^6.15.4",
"vee-validate": "^3.4.3",
"vue": "^2.6.12",
"vue-filepond": "^6.0.3"
},
"devDependencies": {
"#babel/eslint-parser": "^7.16.3",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^7.1.0",
"prettier": "^2.1.2",
"sass": "^1.32.8",
"sass-loader": "^12.3.0"
}
}
Any ideas in what is going on here?
Try in your Dockerfile to set
ENV GIT_SSH_COMMAND='ssh -Tv'
That should give you more clues as to why your SSH key is or is not considered during npm add.
With the help of #VonC's answer I was able to figure out what was going on.
Taking a closer look at the logs, I found out that there is actually a user called node which is used when running npm. Inside the Dockerfile of the Alpine image this user was being created and npm is configured to use this user.
So what happened was whenever I logged into the docker container I was logging in as the root user and all the ssh keys which were set in the Dockerfile were being run by the root user.
Running the ssh -T git#github.com worked because the root user was setup correctly but not the node user
What I still can't get my head around is why did running the command in the /opt folder work? Anyway that's a mystery for a different day.
This is my updated Dockerfile. I set the ssh keys to the node user and login as the node user
FROM node:16.13-alpine
RUN apk add --no-cache openssh-client git
RUN mkdir /app && chown node:node /app
USER node
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN ln -s /run/secrets/ssh_key ~/.ssh/id_rsa
WORKDIR /app
I'm trying to install npm packages for my application within a Dockerfile. However, I get the following error when it comes to installing a package from a private git repository.
Step 9/10 : RUN npm ci
---> Running in 57960fe4df81
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ***github.com/<redacted-private-org>/<redacted-private-repo>.git
npm ERR!
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/<redacted-private-org>/<redacted-private-repo>.git/' not found
npm ERR!
npm ERR! exited with error code: 128
Dockerfile
FROM node:12.18.0-alpine3.10
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh
RUN mkdir -p /home/dev
WORKDIR /home/dev
COPY . /home/dev
RUN npm ci
CMD ["node", "api/api.js"]
package.json
{
"name": "api",
"version": "0.1.0",
"author": "me",
"license": "",
"scripts": {
"prestart": "",
"start": "NODE_ENV=development nodemon ./api/server.js",
},
"dependencies": {
"bcrypt-nodejs": "^0.0.3",
"body-parser": "^1.18.2",
"org-common-utils": "git+https://<redacted-username>:<redacted-token>#github.com/<redacted-private-org>/<redacted-private-repo>.git",
"cors": "^2.8.4",
"dotenv": "^8.2.0",
"express": "^4.16.3",
"express-routes-mapper": "^1.1.0",
"helmet": "^3.12.0",
"igdb-api-node": "^3.1.7",
"jsonwebtoken": "^8.2.1",
"mysql": "^2.16.0",
"mysql2": "^1.6.4",
"node-cache": "^4.2.0",
"sequelize": "^5.21.3",
"sqlite3": "^4.0.0",
},
"devDependencies": {
"cross-env": "^5.1.4",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.18.0",
"husky": "^0.14.3",
"jest": "^22.4.3",
"nodemon": "^1.17.3",
"shx": "^0.2.2",
"supertest": "^3.0.0"
}
}
To install from a private Github repository I'm using a username and token combination as you can see in my package.json.
The repository exists because if I try to navigate to the URL it loads when I'm logged in
https://github.com/redacted-private-org/redacted-private-repo
This issue is only occurring in github actions pipeline.
This issue was only occurring in github actions pipeline. It's solved by setting persist-credentials to false otherwise it uses github actions token which does not have the necessary permissions to pull/install the repository.
.
- name: Checkout
uses: actions/checkout#master
with:
persist-credentials: false
https://github.com/actions/checkout
I am getting this error while running an angular application in docker-compose, but strange enough not getting the error while running with docker run.
docker-compose
Ang-frontend |
Ang-frontend | > Ang-frontend#0.0.0 serve-docker /Ang-frontend
Ang-frontend | > ng serve --proxy-config docker-proxy.conf.json --disable-host-check --host 0.0.0.0 --public-host http://localhost:4200
Ang-frontend |
Ang-frontend | An unhandled exception occurred: Could not find module "#angular-devkit/build-angular" from "/Ang-frontend".
Ang-frontend | Fatal error writing debug log file: ENOENT: no such file or directory, lstat '/tmp'
Ang-frontend | Error: Could not find module "#angular-devkit/build-angular" from "/Ang-frontend".
Ang-frontend | at Object.resolve (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/node_modules/#angular-devkit/core/node/resolve.js:154:11)
Ang-frontend | at WorkspaceNodeModulesArchitectHost.resolveBuilder (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/node_modules/#angular-devkit/architect/node/node-modules-architect-host.js:31:40)
Ang-frontend | at ServeCommand.initialize (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/models/architect-command.js:71:63)
Ang-frontend | at async ServeCommand.validateAndRun (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/models/command.js:124:9)
Ang-frontend | at async Object.runCommand (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/models/command-runner.js:186:24)
Ang-frontend | at async default_1 (/usr/local/nvm/versions/node/v12.14.1/lib/node_modules/#angular/cli/lib/cli/index.js:54:31)
Ang-frontend | npm ERR! code ELIFECYCLE
Ang-frontend | npm ERR! syscall spawn
Ang-frontend | npm ERR! file sh
Ang-frontend | npm ERR! errno ENOENT
Ang-frontend | npm ERR! Ang-frontend#0.0.0 serve-docker: `ng serve --proxy-config docker-proxy.conf.json --disable-host-check --host 0.0.0.0 --public-host http://localhost:4200`
Ang-frontend | npm ERR! spawn ENOENT
Ang-frontend | npm ERR!
Ang-frontend | npm ERR! Failed at the Ang-frontend#0.0.0 serve-docker script.
Ang-frontend | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Ang-frontend | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
Ang-frontend |
Ang-frontend | npm ERR! A complete log of this run can be found in:
Ang-frontend | npm ERR! /root/.npm/_logs/2020-02-02T19_10_50_952Z-debug.log
docker run -p 4200:4200 Ang-frontend
> Ang-frontend#0.0.0 serve-docker /Ang-frontend
> ng serve --proxy-config docker-proxy.conf.json --disable-host-check --host 0.0.0.0 --public-host http://localhost:4200
WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.
Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
WARNING: Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information.
ℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html
chunk {main} main.js, main.js.map (main) 429 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 264 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 165 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 998 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 4.83 MB [initial] [rendered]
Date: 2020-02-02T19:09:33.684Z - Hash: 255ef6ce2bc8407e8f48 - Time: 12189ms
** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Compiled successfully.
package.json
{
"name": "Ang-frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"serve-docker": "ng serve --proxy-config docker-proxy.conf.json --disable-host-check --host 0.0.0.0 --public-host http://localhost:4200"
},
"private": true,
"dependencies": {
"#angular/animations": "~8.2.14",
"#angular/common": "~8.2.14",
"#angular/compiler": "~8.2.14",
"#angular/core": "~8.2.14",
"#angular/forms": "~8.2.14",
"#angular/platform-browser": "~8.2.14",
"#angular/platform-browser-dynamic": "~8.2.14",
"#angular/router": "~8.2.14",
"#ngx-translate/core": "^11.0.1",
"#ngx-translate/http-loader": "^4.0.0",
"bootstrap": "^4.4.1",
"jquery": "^3.4.1",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.23",
"#angular/cli": "~8.3.23",
"#angular/compiler-cli": "~8.2.14",
"#angular/language-service": "~8.2.14",
"#types/node": "~8.9.4",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
dockerfile
FROM debian:buster-slim
SHELL [ "/bin/bash", "--login", "-c" ]
#RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ENV NVM_DIR=/usr/local/nvm NODE_VERSION=12.14.1 NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules PATH=$NVM_DIR/v$NODE_VERSION/bin:$PATH
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential software-properties-common ca-certificates apt-transport-https curl && \
mkdir -p $NVM_DIR && \
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.1/install.sh | bash && \
source $NVM_DIR/nvm.sh && \
nvm install v$NODE_VERSION && \
nvm alias default v$NODE_VERSION && \
nvm use default && \
npm install npm -g && \
apt-get autoremove && \
apt-get clean && \
rm -rf node_modules/ && \
rm -rf /var/lib/apt/lists/*
#
# Application directory
#
WORKDIR /Ang-frontend
ENV PATH=/Ang-frontend/node_modules/.bin:$PATH
#
# copy contents
#
COPY . .
#
# install package dependencies
#
RUN npm install -g #angular/cli#8.3.23 && \
npm update && \
rm -rf /tmp/
EXPOSE 4200
#
# Start the application
#
CMD npm run serve-docker
I am totally confused about this issue. I tried everything with npm update --save dev etc.
The problem still persists.
I dont have much experience in AngluarJs/Node development. If anyone can point me what am I doing wrong then it would be great.
Thank you
I was getting the same error in my mean stack application. Finally, I was able to solve this issue.
The problem is related to volume mounting in docker-compose.yml file.
version: '3'
services:
angular:
build: angular-client
container_name: ecommerce-client
ports:
- "4200:4200"
volumes:
- ./angular-client/:/var/www/app
- /var/www/app/node_modules/ <-- this should be added
So, ./angular-client/:/var/www/app line mounts local angular folder to container's folder. If we don't have node_modules inside local angular project, it means after docker-compose up our local angular folder will override container's folder.
Basically, even if you run npm install inside the container to install all dependencies, at the end, the container folder will be overridden by the local angular folder. And you will lose node_modules package.
To solve this issue, you need to exclude node_modules folder. Adding the line below will be enough to exclude it.
- /var/www/app/node_modules/
P.S.: docker-compose.yml file doesn't read .dockerignore file. .dockerignore file is used by Dockerfile.
I am new to docker and trying to containerise a node app my team have built. Unfortunately, it doesnt seem to build happy.js, a dependency clearly stated in my package.json file.
Here is a copy of my DockerFile:
FROM node:8-alpine
WORKDIR /usr/src/app
ENV UV_THREADPOOL_SIZE 64
COPY cdp-contracts/ ./rpc
COPY cdp-platform/ ./backend
RUN rm -rf backend/node_modules
RUN rm -rf rpc/node_modules
RUN apk add --no-cache --virtual .gyp \
autoconf \
automake \
g++ \
libpng-dev \
libtool \
make \
nasm \
python \
git \
&& npm i -g wait-on concurrently truffle npm#latest \
# && concurrently 'cd rpc; npm init -y ; npm install --save-exact openzeppelin-solidity; npm init -y ; npm i npm#latest -g ' \
# && concurrently 'cd backend; npm init -y ; npm i npm#latest -g ; npm i hapi -g; npm rebuild bcrypt --build-from-source' \
&& concurrently 'cd rpc; npm init -y ; npm install --save-exact openzeppelin-solidity; npm init -y ; npm i npm#latest -g ' \
&& concurrently 'cd backend; npm init -y ; npm i npm#latest -g ; npm i hapi -g; npm rebuild bcrypt --build-from-source' \
&& apk del .gyp
WORKDIR /usr/src/app/rpc
RUN truffle compile --all
WORKDIR /usr/src/app/backend
RUN mkdir -p build/
RUN ln -sf ../../rpc/build/contracts build/contracts
WORKDIR /usr/src/app/backend
EXPOSE 3001
CMD [ "npm", "run", "middleware" ]
The issue is in the backend folder.
Here is a copy of the package.json file copied to this folder:
{
"name": "cdp-platform",
"version": "0.1.0",
"description": "the main platform for CDP",
"main": "server.js",
"private": true,
"scripts": {
"test": "echo ok",
"space{0}": "--- Services ------------------------------------------------",
"middleware": "node ./middleware/server.js",
"middleware:debug": "node --nolazy --inspect-brk=9229 ./middleware/server.js"
},
"repository": {},
"keywords": [],
"author": "",
"license": "",
"dependencies": {
"agentkeepalive": "3.1.0",
"async": "2.5.0",
"axios": "0.18.0",
"bcrypt": "2.0.1",
"bignum": "0.12.5",
"bluebird": "3.5.0",
"boom": "6.0.0",
"csv": "3.1.0",
"csv-parse": "2.5.0",
"documentdb": "1.14.4",
"good": "7.1.0",
"good-console": "6.4.0",
"good-squeeze": "5.0.2",
"greenlock": "2.1.12",
"greenlock-cli": "2.2.6",
"hapi": "16.1.0",
"hapi-auth-jwt2": "7.2.4",
"hapi-authorization": "3.0.3",
"hapi-swagger": "7.9.1",
"http-duplex": "0.0.2",
"inert": "4.2.1",
"is-stream": "1.1.0",
"isemail": "3.0.0",
"joi": "13.0.0",
"jsonwebtoken": "8.1.0",
"lodash": "4.17.10",
"moment": "2.22.1",
"mongodb": "3.0.10",
"pm2": "2.6.1",
"request": "2.80.0",
"scramjet": "4.15.3",
"semver": "5.3.0",
"through": "^2.3.8",
"through2": "^2.0.3",
"toobusy-js": "^0.5.1",
"uuid": "^3.0.1",
"vision": "^4.1.1",
"winston": "^2.3.1",
"xss": "^0.3.3"
},
"devDependencies": {
"babel-eslint": "^8.0.1",
"chai": "^4.1.2",
"eslint": "^4.9.0",
"istanbul": "^0.4.5",
"mocha": "^5.1.1",
"mockery": "^2.0.0",
"nock": "^9.0.9",
"sinon": "^5.0.7"
}
}
Unfortunately, I keep getting this error:
backend_1 | > cdp-platform#0.1.0 middleware /usr/src/app/backend
backend_1 | > node ./middleware/server.js
backend_1 |
backend_1 | module.js:550
backend_1 | throw err;
backend_1 | ^
backend_1 |
backend_1 | Error: Cannot find module 'hapi'
backend_1 | at Function.Module._resolveFilename (module.js:548:15)
backend_1 | at Function.Module._load (module.js:475:25)
backend_1 | at Module.require (module.js:597:17)
backend_1 | at require (internal/module.js:11:18)
backend_1 | at Object.<anonymous> (/usr/src/app/backend/middleware/server.js:2:14)
backend_1 | at Module._compile (module.js:653:30)
backend_1 | at Object.Module._extensions..js (module.js:664:10)
backend_1 | at Module.load (module.js:566:32)
backend_1 | at tryModuleLoad (module.js:506:12)
backend_1 | at Function.Module._load (module.js:498:3)
backend_1 | npm ERR! code ELIFECYCLE
backend_1 | npm ERR! errno 1
backend_1 | npm ERR! cdp-platform#0.1.0 middleware: `node ./middleware/server.js`
backend_1 | npm ERR! Exit status 1
backend_1 | npm ERR!
backend_1 | npm ERR! Failed at the cdp-platform#0.1.0 middleware script.
backend_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
backend_1 | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
backend_1 |
backend_1 | npm ERR! A complete log of this run can be found in:
backend_1 | npm ERR! /root/.npm/_logs/2018-12-04T07_48_39_145Z-debug.log
I would be deeply appreciative of any pointers on this
Your docker file runs npm i hapi -g, so you install hapi globally on the container, but at no point I see you run npm i on your workdir. So I guess your application will not be able to locate any local dependency in node_modules.
I suggest you try adding RUN npm i in your docker file, right after the line WORKDIR /usr/src/app/backend.
I am trying to use docker in order to run npm & bower install.
Here is my configuration:
./package.json
{
"name": "bignibou-client",
"version": "0.1.0",
"engines": {
"node": "0.10.x"
},
"devDependencies": {
"bower": "1.3.12",
"grunt": "~0.4.5",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-concat": "~0.5.0",
"karma": "~0.12.23",
"grunt-karma": "~0.9.0",
"karma-junit-reporter": "~0.2.2",
"karma-jasmine": "~0.1.5",
"karma-phantomjs-launcher": "~0.1.4",
"phantomjs": "~1.9.11",
"grunt-mkdir": "~0.1.2",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-copy": "~0.7.0",
"karma-htmlfile-reporter": "~0.1.2",
"grunt-filerev": "~2.1.2",
"grunt-usemin": "~2.6.2",
"grunt-protractor-runner": "~1.1.4",
"protractor": "~1.4.0",
"flow": "~0.2.3",
"assemble-less": "~0.7.0"
},
"scripts": {
"postinstall": "node_modules/bower/bin/bower install"
}
}
.bowerrc
{
"json": "bower.json", "directory": "bignibou-client/src/bower_components"
}
My command:
docker run --privileged=true -it --rm \
-w /usr/src/app \
-v $(pwd)/package.json:/usr/src/app/package.json \
-v $(pwd)/.bowerrc:/usr/src/app/.bowerrc \
-v $(pwd)/./bower.json:/usr/src/app/bower.json \
-v ./build/npm.tmp/node_modules:/usr/src/app/node_modules \
-v ./build/npm.tmp/bignibou-client/src/bower_components:/usr/src/app/bignibou-client/src/bower_components \
digitallyseamless/nodejs-bower-grunt npm install
I just get the following console output:
npm WARN package.json bignibou-client#0.1.0 No description
npm WARN package.json bignibou-client#0.1.0 No repository field.
npm WARN package.json bignibou-client#0.1.0 No README data
npm WARN package.json bignibou-client#0.1.0 No license field.
and nothing is generated on the host...
Can someone please provide advice as to how to get it working or an alternative solution?
edit:
Running the following command:
docker run --privileged=true -it --rm \
-w /usr/src/app \
-v $(pwd):/usr/src/app \
digitallyseamless/nodejs-bower-grunt npm install
results in:
npm WARN package.json bignibou-client#0.1.0 No repository field.
npm WARN package.json bignibou-client#0.1.0 No license field.
npm WARN cannot run in wd bignibou-client#0.1.0 node_modules/bower/bin/bower install (wd=/usr/src/app)
-v $(pwd)/package.json:/usr/src/app/package.json
this flag will create a package.json directory but not the file.
Here is how your command should look like:
docker run --privileged=true -it --rm \
-w /usr/src/app \
-v $(pwd):/usr/src/app\
digitallyseamless/nodejs-bower-grunt bash -c "npm install && bower --allow-root install"
And after this script create node_modules and bower_components in current directory on HOST mashine and you can manipulate with result as you wish.