yarn run Error: spawn EACCES in JHipster - node.js

i'm creating project with jhipster Version 4.7.0.
when i run the angular, with yarn run webpack:dev --watch-content-base
shows me error like below.
yarn start v0.27.5
$ yarn run webpack:dev --watch-content-base
10% building modules 4/4 modules 0 active[HPM] Proxy created: [ '/api',
'/management',
'/swagger-resources',
'/v2/api-docs',
'/h2-console' ] -> http://localhost:8080
Project is running at http://localhost:9060/
webpack output is served from /
Content not from webpack is served from ./target/www
11% building modules 13/20 modules 7 active ...modules/style-loader/lib/addStyles.jsWarning: The 'no-use-before-declare' rule requires type infomation.
[at-loader] Using typescript#2.4.2 from typescript and "tsconfig.json" from /Users/user/Documents/myproject/tsconfig.json.
136040ms building modules
303ms sealing
1ms optimizing
0ms basic module optimization
74ms module optimization
0ms advanced module optimization
109ms basic chunk optimization
0ms chunk optimization
0ms advanced chunk optimization
0ms module and chunk tree optimization
0ms chunk modules optimization
1ms advanced chunk modules optimization
40ms module reviving
137ms module order optimization
22ms module id optimization
15ms chunk reviving
0ms chunk order optimization
132ms chunk id optimization
200ms hashing
3ms module assets processing
26852ms chunk assets processing
8863ms additional chunk assets processing
20ms recording
0ms additional asset processing
0ms chunk asset optimization
94% asset optimization
[at-loader] Checking started in a separate process...
[at-loader] Ok, 0.256 sec.
MergetJsonsWebpackPlugin compilation started...
MergetJsonsWebpackPlugin compilation completed...
1052ms asset optimization
95% emittingMergetJsonsWebpackPlugin emit starts...
MergetJsonsWebpackPlugin emit completed...
Error: spawn EACCES
at exports._errnoException (util.js:1024:11)
at ChildProcess.spawn (internal/child_process.js:325:11)
at exports.spawn (child_process.js:493:9)
at Object.exports.execFile (child_process.js:208:15)
at Object.module.exports.fileCommand (/Users/user/Documents/myproject/node_modules/node-notifier/lib/utils.js:53:13)
at NotificationCenter.notify (/Users/user/Documents/myproject/node_modules/node-notifier/notifiers/notificationcenter.js:66:11)
at module.exports.WebpackNotifierPlugin.compilationDone (/Users/user/Documents/myproject/node_modules/webpack-notifier/index.js:62:18)
at Compiler.applyPlugins (/Users/user/Documents/myproject/node_modules/tapable/lib/Tapable.js:61:14)
at Watching._done (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:104:17)
at compiler.emitRecords.err (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:78:19)
at Compiler.emitRecords (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:375:38)
at compiler.emitAssets.err (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:61:20)
at applyPluginsAsyncSeries1.err (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:368:12)
at next (/Users/user/Documents/myproject/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/user/Documents/myproject/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at next (/Users/user/Documents/myproject/node_modules/tapable/lib/Tapable.js:220:14)
at Compiler.compiler.plugin (/Users/user/Documents/myproject/node_modules/merge-jsons-webpack-plugin/index.js:47:17)
at next (/Users/user/Documents/myproject/node_modules/tapable/lib/Tapable.js:220:14)
at callback (/Users/user/Documents/myproject/node_modules/copy-webpack-plugin/dist/index.js:108:17)
at Compiler.<anonymous> (/Users/user/Documents/myproject/node_modules/copy-webpack-plugin/dist/index.js:131:13)
at Compiler.applyPluginsAsyncSeries1 (/Users/user/Documents/myproject/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/Users/user/Documents/myproject/node_modules/webpack/lib/Compiler.js:365:9)
error Command failed with exit code 1.
error Command failed with exit code 1.
error Command failed with exit code 1.
can anybody explain to me what is happen?
and how to fix it.
i'm running macOS Sierra.
NodeJS 6.11.3 LTS.
thanks.

Related

process of webpack build exits unexpectedly in docker container

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 ....

Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException;

I have a simple Express/Node.js application with the following files with no subdirectories (other than .serverless and node_modules).
.serverless
node_modules
app.js
lambda.js
package.json
package-lock.json
serverless.yml
AWS throws this error - An error occurred: ApiLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 5779d4c3-beaa-4bc2-b525-c1e89a82635a; Proxy: null).
The .zip file was not empty when I accessed the S3 bucket to which the code gets uploaded. I was able to see the .zip folder with all its contents in there, However, the serverless deploy operation fails from AWS CLI, throwing the above exception. Any help to zero in on the problem would be greatly appreciated. Thanks!
Following is the code.
app.js
const express = require("express")
const app = express();
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.get("/", (req, res) => {
res.status(200).send("Root endpoint")
})
app.post("/postReq", (req, res) => {
res.status(200).send(req.body);
})
app.listen(8080, () => console.log("App started."))
lambda.js
'use strict'
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')
const server = awsServerlessExpress.createServer(app)
exports.handler = (event, context) => { awsServerlessExpress.proxy(server, event, context) }
package.json
{
"name": "my-lambda",
"version": "1.0.0",
"description": "Lambda Function",
"main": "app.js",
"scripts": {
"start": "node app.js",
"deploy": "serverless deploy"
},
"author": "Aseem Savio",
"license": "ISC",
"dependencies": {
"aws-serverless-express": "^3.4.0",
"express": "^4.17.1"
},
"devDependencies": {
"serverless": "^2.21.1"
}
}
serverless.yml
service: my-lambda-function
provider:
name: aws
runtime: nodejs10.x
memorySize: 512
timeout: 15
stage: production
region: ap-south-1
functions:
api:
handler: lambda.handler
events:
- http: ANY {proxy+}
- http: ANY /
The following is the console logs.
aseemsavio#aseem-ubuntu:~/projects/Node.js/my-lambda$ npm run deploy
> my-lambda#1.0.0 deploy
> serverless deploy
Serverless: Configuration warning at 'functions.api.events[0].http': value 'ANY {proxy+}' does not satisfy pattern /^(?:\*|(GET|POST|PUT|PATCH|OPTIONS|HEAD|DELETE|ANY) (\/\S*))$/i
Serverless:
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:
Serverless: Deprecation warning: Starting with next major version, default value of provider.lambdaHashingVersion will be equal to "20201221"
More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service my-lambda.zip file to S3 (917.12 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
................
Serverless: Operation failed!
Serverless: View the full error output: https://ap-south-1.console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aap-south-1%3A617584887932%3Astack%2Fmy-lambda-production%2F6d6f6ed0-607d-11eb-a05e-02c8952955f8
Serverless Error ---------------------------------------
An error occurred: ApiLambdaFunction - Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 5779d4c3-beaa-4bc2-b525-c1e89a82635a; Proxy: null).
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: linux
Node Version: 15.6.0
Framework Version: 2.21.1 (local)
Plugin Version: 4.4.2
SDK Version: 2.3.2
Components Version: 3.5.1
npm ERR! code 1
npm ERR! path /home/aseemsavio/projects/Node.js/my-lambda
npm ERR! command failed
npm ERR! command sh -c serverless deploy
npm ERR! A complete log of this run can be found in:
npm ERR! /home/aseemsavio/.npm/_logs/2021-01-27T09_38_04_670Z-debug.log
aseemsavio#aseem-ubuntu:~/projects/Node.js/my-lambda$
The full logs from the debug file are as follows:
0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
1 info using npm#7.4.0
2 info using node#v15.6.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
5 timing config:load:builtin Completed in 0ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/aseemsavio/projects/Node.js/my-lambda/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/aseemsavio/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 5ms
19 verbose npm-session 39866318e36c1c25
20 timing npm:load Completed in 11ms
21 timing command:run-script Completed in 49470ms
22 verbose stack Error: command failed
22 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/#npmcli/promise-spawn/index.js:64:27)
22 verbose stack at ChildProcess.emit (node:events:379:20)
22 verbose stack at maybeClose (node:internal/child_process:1065:16)
22 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:296:5)
23 verbose pkgid my-lambda#1.0.0
24 verbose cwd /home/aseemsavio/projects/Node.js/my-lambda
25 verbose Linux 5.8.0-38-generic
26 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
27 verbose node v15.6.0
28 verbose npm v7.4.0
29 error code 1
30 error path /home/aseemsavio/projects/Node.js/my-lambda
31 error command failed
32 error command sh -c serverless deploy
33 verbose exit 1
This problem is caused by the archiverjs/node-archiver dependency used inside serverless when running on node version 15.6.0 or higher currently.
As many proposed here downgrading the node version to the current LTS version v14.15.4 or v15.5.1 should work just fine as MX D mentioned in his comment.
Many people are experiencing this issue when building their bundles inside a CI/CD Pipeline, because they are using a node docker image.
For example in GitLab like:
default:
image: node:alpine
Instead of node:alpine, the error should also occur with node:latest, etc. The lines should be changed to a specific working version described above as follows:
default:
image: node:15.5.1
Just upgrade the serverless to the newest version: https://www.serverless.com/framework/docs/getting-started#upgrade
Had same problem today with a node lambda. To Fix
Globally Update SLS
Update in package.json:
webpack
serverless-webpack
That fixed it. Those packages were not updated in 3 years. My bad.
I also went into AWS Lambda and updated to Node 16. But that didn't fix it.
Node JS latest: 19.4.0 - Didn't work
Node JS 18.13.0 LTS - Didn't work
Node JS 14.20.0 - WORKED!!!
Installing latest serverless package not helped
I had the same issue when deploying to Netlify. In my case, I was accidentally deploying an empty lambda function which caused the issue. Hope that helps someone!

Angular-cli 'JavaScript heap out of memory' on asset optimization

I'm creating a leaflet map inside an Angular-cli project. Map tiles are stored locally in the 'assets' folder because it's a raster map. The problem is when I've many zoom levels of the map, I've more than 280 thousands images with approximate size of 1.1 GB and It will get bigger.
when I use ng serve here is the console output (it is stuck # assets optimization):
** NG Live Development Server is running on http://localhost:4200. **
25234ms building modules
69ms sealing
0ms optimizing
0ms basic module optimization
96ms module optimization
1ms advanced module optimization
16ms basic chunk optimization
0ms chunk optimization
1ms advanced chunk optimization
0ms module and chunk tree optimization
179ms module reviving
9ms module order optimization
4ms module id optimization
6ms chunk reviving
23ms chunk order optimization
36ms chunk id optimization
61ms hashing
1ms module assets processing
149ms chunk assets processing
4ms additional chunk assets processing
0ms recording
1ms additional asset processing
2693ms chunk asset optimization
94% asset optimization
<--- Last few GCs --->
119106 ms: Mark-sweep 1333.6 (1409.7) -> 1333.6 (1415.7) MB, 1402.0 / 2.1 ms [allocation failure] [GC in old space requested].
120570 ms: Mark-sweep 1333.6 (1415.7) -> 1333.6 (1427.7) MB, 1464.2 / 2.2 ms [allocation failure] [GC in old space requested].
122079 ms: Mark-sweep 1333.6 (1427.7) -> 1340.0 (1409.7) MB, 1508.1 / 2.5 ms [last resort gc].
123749 ms: Mark-sweep 1340.0 (1409.7) -> 1346.3 (1409.7) MB, 1670.2 / 2.1 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000001AA792CFB61 <JS Object>
1: inflight [C:\Workspace\node_modules\inflight\inflight.js:~7] [pc=00000202BF9894B7] (this=000001AA792E6661 <JS Global Object>,key=00000045863E5881 <Strin
g[90]\: lstat\x00C:/Workspace/src/assets/leafletmap_files/9/42/176.png>,cb=00000045863E5839 <JS Function lstatcb_ (SharedFunctionInfo 00000253E9EFC219
)>)
2: wrapper [C:\Workspace\...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I tried using:
node --max_old_space_size=8192 --optimize_for_size --max_executable_size=4096 --stack_size=4096, but It doesn't make any difference.
1- Is there is any other way to avoid optimizing all the assets folder? If it is the source of the problem as I think, because the project were running smoothly before adding more leaflet tile images.
2- Is there are any workarounds to solve this issue?
UPDATE:
There is an open issue at Angular-cli repository related to this question.
Add the below line to package.json file.
"aot": "node --max-old-space-size=8192 ./node_modules/#angular/cli/bin/ng build --prod --aot"
and try running with npm run aot
It worked for me.
You can add NODE_OPTIONS as a system variable. To set memory to 4 gigs,
--max-old-space-size=4096
Lots more info on this thread, they deserve the votes
For those who get the same error, I solved the problem by changing global ng.cmd file.
C:\Users\userName\%AppData%\Roaming\npm
Copy/paste the following code into your ng.cmd.
#IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8048 "%~dp0\node_modules\#angular\cli\bin\ng" %*
) ELSE (
#SETLOCAL
#SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8048 "%~dp0\node_modules\#angular\cli\bin\ng" %*
)
node --max_old_space_size=8192 node_modules/#angular/cli/bin/ng serve
Open Terminal and add this above text in your terminal and click enter .
that's it .
Add this line to package.json file.
"build": "node --max_old_space_size=8192 node_modules/#angular/cli/bin/ng build --prod"
Error faced while running "ng serve --open"
Source Link
Solution
In package.json "scripts" property update it to following
**"start": "node --max_old_space_size=2192 ./node_modules/#angular/cli/bin/ng serve",**
Run the following command in terminal:
node --max_old_space_size=10048 ./node_modules/#angular/cli/bin/ng serve
For Angular SSR (server side rendering)
If you are trying to run ng run dev:ssr and getting memory errors, you can do this:
node --max_old_space_size=8000 ./node_modules/#angular/cli/bin/ng run ANGULAR:serve-ssr -c development
Change ANGULAR to whatever your project is called in angular.json.
-c is the optional configuration you want to run.
In my case, I had to downgrade the node version to v12.14.1 and it works fine now!!

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.

EPERM during gulp commands

I have a gulpfile that I am using together with Browserify, Babelify and BrowserSync to implement my build workflow. However, I am constantly having problems with EPERM errors in Node.js.
I first had an error in my gulp clean task that used rimraf in order to clean my dist directory. The task would occasionaly throw an error (I was not able to reproduce the error 100% of attempts though). The error was an EPERM that complained about the unlink action for ./dist/app.js. I tried using del instead of rimraf and for some reason it helped.
However, if I run gulp watch and something changes , there is very often this error now:
(node:10740) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[22:52:35] Using gulpfile D:\Workspace\milestones\gulpfile.js
[22:52:35] Starting 'clean'...
[22:52:35] Finished 'clean' after 4.2 ms
[22:52:35] Starting 'build-persistent'...
[22:52:37] Finished 'build-persistent' after 1.55 s
[22:52:37] Starting 'watch'...
[22:52:37] Finished 'watch' after 92 ms
[BS] Local URL: http://localhost:3000
[BS] External URL: http://192.168.0.108:3000
[BS] Serving files from: ./
[22:52:48] Starting 'clean'...
[22:52:48] Finished 'clean' after 2.77 ms
[22:52:48] Starting 'build-persistent'...
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: EPERM: operation not permitted, open 'D:\Workspace\milestones\dist\app.js'
at Error (native)
The full gulpfile may be seen in the gist here.
I am running Windows 10.
Update: The issue seems to be absent when running gulp build and therefore might be caused by BrowserSync.

Resources