process of webpack build exits unexpectedly in docker container - node.js

my front end project is huge, it consume lots of memory in building. The command looks like this:
cross-env NODE_ENV=production NODE_OPTIONS='--max_old_space_size=20480' webpack build --config config/webpack.prod.js --env OM_MODULE=all
The build can success in physical machine, but failed unexpectedly in docker container with the following log:
> cross-env NODE_ENV=production NODE_OPTIONS='--max_old_space_size=20480' webpack build --config config/webpack.prod.js --env OM_MODULE=all
 ELIFECYCLE  Command failed with exit code 1.
To get more details, I have tried to run the dev command cross-env NODE_ENV=development node scripts/rundev.js, and I can get a little more.
<s> [webpack.Progress] 86% sealing record chunks RecordIdsPlugin
<s> [webpack.Progress] 86% sealing record chunks
<s> [webpack.Progress] 87% sealing module hashing
<s> [webpack.Progress] 87% sealing module hashing
<s> [webpack.Progress] 87% sealing code generation
<s> [webpack.Progress] 87% sealing code generation
Error: Command failed: npm run start:dev:module -- --env OM_MODULE=all PORT=8080 REFRESH=true
at checkExecSyncError (node:child_process:861:11)
at execSync (node:child_process:932:15)
at runCommandSync (/home/jenkins/workspace/om-tag-integration-abovec60spc100-tmp/onemind-web/scripts/rundev.js:85:3)
at /home/jenkins/workspace/om-tag-integration-abovec60spc100-tmp/onemind-web/scripts/rundev.js:173:7
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 2403,
stdout: null,
stderr: null
}
the error log is truncated and very strange.
I think it may be caused by memory, so I have tried to run the docker container with following command, but no luck, anyone can help me out?
docker run -m=5g --memory-swap=-1 ....

Related

ts-node permission denied in Docker

Running Express js server with pnpm in container gives permission error during start like this:
> pnpm run --filter=#workspace/mypackage dev
> #workspace/mypackage#1.0.0 dev /app/packages/mypackage
> nodemon
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node ./src/index.ts`
sh: ts-node: Permission denied
[nodemon] app crashed - waiting for file changes before starting...
pnpm unsafe-perm is already set true and corepack enabled.
My package json looks like this:
...
"scripts": {
"dev": "nodemon"
},
...
"dependencies": {
"express": "^4.18.2"
},
"devDependencies": {
"nodemon": "^2.0.20",
"ts-node": "^10.9.1"
}
Update: just found that ts-node is not installed during build by testing ts-node in the last step of docker build. So the problem turns out to be why pnpm didn't install dev dependency of a package which is ts-node.
Docker build logs:
#14 [stage-1 7/8] RUN ts-node -e 'console.log("Hello, world!")'
#14 sha256:e75e2e17e660efaa7407c1bbeaf48e9d7d4ac754facc168f35cdd1f51ff00b91
#14 0.346 /bin/sh: ts-node: not found
#14 ERROR: executor failed running [/bin/sh -c ts-node -e 'console.log("Hello, world!")']: exit code: 127
------
> [stage-1 7/8] RUN ts-node -e 'console.log("Hello, world!")':
------
executor failed running [/bin/sh -c ts-node -e 'console.log("Hello, world!")']: exit code: 127

Npm run sls multi offline keeps getting terminated

I'm trying to run npm run sls-multi-offline (I have "start": "sls-multi-offline" in package.json file) but it keeps getting terminated without giving any error message or warning other than exited with code 0. This is what it looks like:
> start
> sls-multi-offline
[HPM] Proxy created: / -> http://localhost:3100/dev/
[HPM] Proxy created: / -> http://localhost:3101/dev/
[auth]
[auth] cd C:\Users\HP\Desktop\coreservices/./services/auth;
[auth] npx sls offline --stage dev --httpPort 3101 --lambdaPort 4101
[auth] exited with code 0
--> Sending SIGTERM to other processes..
[accounts]
[accounts] cd C:\Users\HP\Desktop\coreservices/./services/accounts;
[accounts] npx sls offline --stage dev --httpPort 3100 --lambdaPort 4100
[accounts] exited with code 0
PS C:\Users\HP\Desktop\coreservices>
What could be causing this?

jit-grunt: Plugin for the "watch" task not found

after executing >> "grunt server" i saw these errors i don't know what and where i need to attach or detach some code.
one more thing DeprecationWarning: while nowhere in the code i wrote node --debug and node --debug-brk.
$ grunt server
Running "server" task
>> The `server` task has been deprecated. Use `grunt serve` to start a server.
Running "serve" task
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "env:all" (env) task
Running "express:dev" (express) task
Starting background Express server
(node:5497) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
Stopping Express server
Running "wait" task
>> Waiting for server reload...
Done waiting!
jit-grunt: Plugin for the "watch" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "watch" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-09-25 12:24:48 UTC+5:30)
loading tasks 124ms ▇▇▇▇ 7%
express:dev 106ms ▇▇▇ 6%
wait 1.5s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85%
Total 1.8s
Solution
npm install grunt-contrib --save-dev
and add this line before the last line of grunt.js:
grunt.loadNpmTasks('grunt-contrib');

WebPack module build error

Having trouble with building react project with WebPack.
Getting the following error output, is there a way to get a more info out of web pack on this issue.
running: webpack --display-error-details --display-reasons --progress -p --config webpack.config.prod.js
62% 478/543 build modulesError
at NormalModule.<anonymous> (...../node_modules/webpack/lib/NormalModule.js:113:20)
at NormalModule.onModuleBuild (..../node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (..../node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at ...node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (....node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at .../node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:438:3)
69% 1917/1919 build modules

On Windows, wepback build is blocked during 'emit' phase

I created a simple webpack project for a Typescript library : https://github.com/lbar/test-webpackts-issue
On linux, npm run build finishes successfully:
> rimraf dist && webpack --progress --profile
10% 0/1 build modulests-loader: Using typescript#1.8.10 and /tmp/testwebpack/tsconfig.json 8030ms1217ms optimi5ms emit
Hash: 8eac1502f3b7a9a19be2
Version: webpack 1.13.1
Time: 2596ms
Asset Size Chunks Chunk Names
index.js 816 bytes 0 [emitted] index
index.js.map 6.07 kB 0 [emitted] index
/tmp/testwebpack/dist/index.d.ts 31 bytes [emitted]
/tmp/testwebpack/dist/src/info.d.ts 49 bytes [emitted]
+ 2 hidden modules
On Windows, npm run build is blocked during 'emit' phase. The output is :
> rimraf dist && webpack --progress --profile
10% 0/1 build modulests-loader: Using typescript#1.8.10 and C:\tmp\testwebpack\tsconfig.jso
1836ms build modules
3ms seal
7ms optimize
3ms hashing
7ms create chunk assets
79ms additional chunk assets
19ms optimize chunk assets
837ms optimize assets
95% emit
The version of node differs: 6.2.2 on Windows and 4.4.5 on Linux. I don't know if it may be the cause.
Has anyone an idea about the problem? Issue in webpack, ts-loader or typescript?
One more thing, call to tsc is working on both systems.
Thanks for your help
This problem is caused by an issue in ts-loader: https://github.com/TypeStrong/ts-loader/issues/185
A Pull Request is waiting fixes for project core team.
Webpack can use "awesome-typescript-loader" to avoid this issue.

Resources