My Node.js project won't load on docker.
As you can see the index can't load.
Here is the code:https://github.com/tech-387/spartan-apps-admin-console-frontend
Here is the error I get:
npm#1.0.0 start /home/node/app
node ./bin/www
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module './src/Presentation/viewModel/index'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /home/node/app/app.js:29:18
at Array.forEach ()
at Object. (/home/node/app/app.js:28:26)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! npm#1.0.0 start: node
./bin/www npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
npm#1.0.0 start 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!
/root/.npm/_logs/2019-05-09T09_13_02_678Z-debug.log
And here is my docker file:
FROM node:10-alpine
WORKDIR /home/node/app
COPY app.js /home/node/app
COPY bin /home/node/app/bin
COPY config /home/node/app/config
COPY public /home/node/app/public
COPY scratch /home/node/app/scratch
COPY src /home/node/app/src
COPY package.json /home/node/app
COPY package-lock.json /home/node/app
RUN npm install
EXPOSE 3000
# Start the app
CMD npm start
Related
I have a react app that fails when I try to Dockerize it. The command to install as follows
npm install
runs well. However when I try to Dockerize using the Docker file below (worked a few weeks before), it fails:
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
FROM tiangolo/node-frontend:10 as build-stage
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package*.json /app/
# RUN npm set unsafe-perm true
RUN npm ci
RUN npm install
COPY . .
RUN npm run build
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:stable-alpine
COPY --from=build-stage /app/build/ /usr/share/nginx/html
# Copy the default nginx.conf provided by tiangolo/node-frontend
COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf
The error I get is as follows:
/app/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
_ending;
^
SyntaxError: Unexpected token ;
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.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! /root/.npm/_logs/2022-09-07T16_05_39_905Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
I have tried several upgrading and downgrading node to various versions eg 14, 16, 18 but still get the same error. Kindly advice
I am trying to use npm run build and I am unable to run is as I am being told that \node_modules\tablemark\dist\index.js is not found. The error is as follows:
> node .
internal/modules/cjs/loader.js:456
throw e;
^
Error: Cannot find module 'D:\Avin Dev\dev-hearts\node_modules\tablemark\dist\index.js'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
at resolveExports (internal/modules/cjs/loader.js:450:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (D:\Avin Dev\dev-hearts\index.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
code: 'MODULE_NOT_FOUND',
path: 'D:\\Avin Dev\\dev-hearts\\node_modules\\tablemark\\package.json'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hearts#1.0.0 build: `node .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hearts#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\avini\AppData\Roaming\npm-cache\_logs\2021-11-08T07_10_51_261Z-debug.log
So far I have tried:
Completely reinstalling npm.
Installing tablemark separately using npm install tablemark
My NPM version is: 6.14.15 and my Node version is v14.18.1
I keep getting the following error:
> kb-ui#0.0.1 start C:\Users\Tayeb\Desktop\F2f\bloomkonnect-fe
> webpack-dev-server --open --config webpack.dev.js --progress --watch
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'json-parse-better-errors'
Require stack:
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\webpack.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\Compiler.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\webpack.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! kb-ui#0.0.1 start: `webpack-dev-server --open --config webpack.dev.js --progress --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the kb-ui#0.0.1 start 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\Tayeb\AppData\Roaming\npm-cache\_logs\2021-06-23T17_23_33_473Z-debug.log
I have tried doing the following:
remove the node modules folder and run npm install
remove the node modules and package lock json and do npm install
re install node.js
delete the clone the repository again
I dont get what is wrong. When I look inside the node modules folder the module it is saying is missing is there. This is driving me nuts.
I'm building a docker image for a Node.js project and among other dependecies it has "zeromq": "^5.2.0" (which most likely caused the error below).
The dockerfile is:
# We are using the latest Node.js distribution with Long Term Support (LTS) as of 11/04/2020.
FROM node:14.15
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm#5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
RUN npm run build
EXPOSE 3000
CMD [ "node", "dist/src/app.js" ]
When running a docker instance I receive the following logs
server /usr/src/app
> node dist/src/app.js
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /usr/src/app/node_modules/zeromq/build/Release/zmq.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
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)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/usr/src/app/node_modules/zeromq/lib/index.js:6:11)
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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bitcoin-broadcast-server#1.3.0 server: `node dist/src/app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitcoin-broadcast-server#1.3.0 server 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! /root/.npm/_logs/2021-03-05T11_31_06_652Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bitcoin-broadcast-server#1.3.0 start: `npm run server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitcoin-broadcast-server#1.3.0 start 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! /root/.npm/_logs/2021-03-05T11_31_06_791Z-debug.log
The error message (Error: /usr/src/app/node_modules/zeromq/build/Release/zmq.node: invalid ELF header) points out the the ZeroMQ binary is corrupted, but I can't find any fix for it.
I have successfully installed a vuetifyjs template using the command
vue init vuetifyjs/webpack-advanced
it was successfully installed but when I tried to use the command npm run dev I had the following error message:
C:\Users\Muse\Documents\vuetify>npm run dev
vuetify#1.0.0 dev C:\Users\Muse\Documents\vuetify
node build/dev-server.js
fs.js:1657
binding.lstat(baseLong);
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\Muse\Documents\vuetify\test'
at Object.realpathSync (fs.js:1657:15)
at resolve (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:8:13)
at Object. (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:35:35)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vuetify#1.0.0 dev: node build/dev-server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuetify#1.0.0 dev 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\Muse\AppData\Roaming\npm-cache_logs\2017-08-31T09_19_06_701Z-debug.log
You just need to create a test folder and give it access.
It's a bug with webpack-advanced template
Fore install your project dependencies
npm install -f
Then, make a folder named "test" in your root project
mkdir test
It's a bug caused by vuetifyjs/webpack-advanced