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.
Related
Getting error when running npm run build:
Can any one help me to fix this issue.
Package.json file:
{
"name": "confusion",
"version": "1.0.0",
"description": "This is a website for Ristorante Con Fusion",
"main": "index.html",
"scripts": {
"start": "npm run watch:all",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server",
"scss": "node-sass -o css/ css/",
"watch:scss": "onchange \"css/*.scss\" -- npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\"",
"clean": "rimraf dist",
"copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",
"imagemin": "imagemin img/* --out-dir=dist/img",
"usemin": "usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html",
"build": "npm run clean && npm run imagemin && npm run copyfonts && npm run usemin"
},
"author": "",
"license": "ISC",
"devDependencies": {
"cssmin": "^0.4.3",
"htmlmin": "0.0.7",
"lite-server": "^2.5.4",
"micromatch": "^4.0.2",
"node-sass": "^4.14.1",
"onchange": "^3.3.0",
"parallelshell": "^3.0.1",
"rimraf": "^2.6.2",
"uglify-js": "^3.11.6",
"usemin-cli": "^0.6.0"
},
"dependencies": {
"bootstrap": "^4.0.0",
"bootstrap-social": "^5.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"popper.js": "^1.12.9"
}
}
ERROR
PS I:\Projects\Bootstrtao-test> npm run build
> confusion#1.0.0 build I:\Projects\Bootstrtao-test
> npm run clean && npm run imagemin && npm run copyfonts && npm run usemin
> confusion#1.0.0 clean I:\Projects\Bootstrtao-test
> rimraf dist
> confusion#1.0.0 imagemin I:\Projects\Bootstrtao-test
> imagemin img/* --out-dir=dist/img
4 images minified
> confusion#1.0.0 copyfonts I:\Projects\Bootstrtao-test
> copyfiles -f node_modules/font-awesome/fonts/* dist/fonts
> confusion#1.0.0 usemin I:\Projects\Bootstrtao-test
> usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html
I:\Projects\Bootstrtao-test\node_modules\usemin\lib\processBlocks.js:39
throw Error('Unsupport format: ' + block.type);
^
Error: Unsupport format: CSS
at I:\Projects\Bootstrtao-test\node_modules\usemin\lib\processBlocks.js:39:10
at Array.forEach (<anonymous>)
at module.exports (I:\Projects\Bootstrtao-test\node_modules\usemin\lib\processBlocks.js:9:9)
at usemin (I:\Projects\Bootstrtao-test\node_modules\usemin\usemin.js:27:42)
at Object.<anonymous> (I:\Projects\Bootstrtao-test\node_modules\usemin-cli\index.js:52:12)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion#1.0.0 usemin: `usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion#1.0.0 usemin script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\PetrosBelachew\AppData\Roaming\npm-cache\_logs\2020-11-20T12_05_10_237Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion#1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\PetrosBelachew\AppData\Roaming\npm-cache\_logs\2020-11-20T12_05_10_452Z-debug.log
Any ideas on how to fix this?
I have fixed the issue by myself,after observing the error above(Error: Unsupport format: CSS).Then checked my index.html file,that the code like this
<!--build:CSS CSS/main.css-->
.....
<!--endbuild-->
on this line above,you can see that CSS has to be lower case css.After that I have solved other issues within my HTML file.Then the build was successful.
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
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 creating a simple HelloWorld application using Node and react. I followed this tutorial when I run
npm start
I get the following error:
> test1#1.0.0 start C:\Users\Saeed\Work\Test1
> webpack-dev-server
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
module.js:549
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Saeed\Work\Test1\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test1#1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test1#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
this is my package.json:
{
"name": "test1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"webpack": "^4.16.3",
"webpack-dev-server": "^3.1.5"
}
}
can anyone one point me out to my error? I npm install webpack-cli -D would solve the problem.
I'm developing a multi-module docker nodejs app with docker-compose. There's an issue with the natural node package needed by a module. It seems that it can't exec it. I tried to rebuild it on the fly with a RUN command, but nothing changed.
Here's the log when trying to run docker-compose up:
web_1 | /app/web-server/node_modules/natural/lib/natural/classifiers/classifier.js:32
web_1 | if (e.code !== 'MODULE_NOT_FOUND') throw e;
web_1 | ^
web_1 |
web_1 | Error: Error loading shared library /app/web-server/node_modules/webworker-threads/build/Release/WebWorkerThreads.node: Exec format error
web_1 | at Error (native)
web_1 | at Object.Module._extensions..node (module.js:597:18)
web_1 | at Module.load (module.js:487:32)
web_1 | at tryModuleLoad (module.js:446:12)
web_1 | at Function.Module._load (module.js:438:3)
web_1 | at Module.require (module.js:497:17)
web_1 | at require (internal/module.js:20:19)
web_1 | at bindings (/app/web-server/node_modules/bindings/bindings.js:81:44)
web_1 | at Object.<anonymous> (/app/web-server/node_modules/webworker-threads/index.js:1:105)
web_1 | at Module._compile (module.js:570:32)
web_1 | at Object.Module._extensions..js (module.js:579:10)
web_1 | at Module.load (module.js:487:32)
web_1 | at tryModuleLoad (module.js:446:12)
web_1 | at Function.Module._load (module.js:438:3)
web_1 | at Module.require (module.js:497:17)
web_1 | at require (internal/module.js:20:19)
Here's the package.json:
{
"name": "realaffinities",
"version": "1.0.0",
"description": "",
"main": "server/Server.js",
"keywords": [],
"author": "",
"license": "GPL-3.0",
"dependencies": {
"async": "^2.5.0",
"big-integer": "^1.6.23",
"body-parser": "1.9.0",
"express": "^4.15.3",
"express-validator": "^3.2.1",
"knex": "^0.13.0",
"mysql": "^2.14.1",
"natural": "^0.5.4",
"twit": "^2.2.9",
"url-exists": "^1.0.3",
"nodemon": "^1.11.0"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-express-server": "^0.5.3",
"mocha": "^3.4.2",
"supertest": "^3.0.0",
"bcrypt": "1.0.2"
},
"scripts": {
"test": "mocha web-server/test",
"start": "node server/Server.js"
}
}
My dockerfile:
FROM node:6.11-alpine
EXPOSE 3000
ENV NODE_ENV development
RUN mkdir /app
WORKDIR /app
# add package.json and run npm install before adding the rest of the files
# this way, you only run npm install when package.json changes
ADD /web-server/package.json /app/package.json
RUN apk add --no-cache make gcc g++ python
RUN npm install -g mocha
RUN npm install
I don't know whether it's an issue of this particular node package or a knowledge lack of mine. If I run the same application locally on my mac without docker, it doesn't encounter this problem.
Someone reported same problem in this issue and his case was similar to yours. As discussed in comments, this worked for you, so I am posting this as answer also:
It sounds like it's trying to load a native extension that wasn't
compiled for linux (in the container) -- maybe you previously
installed the extension on OS X and it's trying to load that binary.
If you mean this is a node app, try just removing node_modules and run
npm install again
Fix that worked for you: rm -rf node_modules
Create a .dockerignore file and add /node_modules
None of the answers above worked for me. Switching from bcrypt to bcryptjs was what worked.
docker build --platform linux/amd64 .
Instead of the default arm64, this sometimes works.