node/npm/yarn error on installing vulnerable packages - node.js

I've been facing issues when installing packages with npm on Windows 10, I tried yarn too, but no luck
Very Important: I have noticed that only packages with 0 vulnerabilities are actually installable, others simply fail:
for example npx create-next-app:
npx create-next-app next
'CALL "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (x86)\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ENOENT
npm ERR! syscall spawn C:\WINDOWS\system32\cmd.exe;
npm ERR! path C:\Users\my\Desktop\Web Projects\MiraWebNext
npm ERR! errno -4058
npm ERR! enoent spawn C:\WINDOWS\system32\cmd.exe; ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\my\AppData\Local\npm-cache\_logs\2022-10-01T19_48_18_363Z-debug-0.log
when trying yarn create next-app however:
success Installed "create-next-app#12.3.1" with binaries:
- create-next-app
error Couldn't find the binary C:\Users\my\AppData\Local\Yarn\bin\create-next-app
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
I went to Local\Yarn\bin and create-next-app was there! so I manually ran it with cmd, this time:
√ What is your project named? ... my-app
Creating a new Next.js app in C:\Users\my\AppData\Local\Yarn\bin\my-app.
Using npm.
Installing dependencies:
- react
- react-dom
- next
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn C:\WINDOWS\system32\cmd.exe; ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.e.emit (C:\Users\my\AppData\Local\Yarn\Data\global\node_modules\create-next-app\dist\index.js:38:8292)
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn C:\\WINDOWS\\system32\\cmd.exe;',
path: 'C:\\WINDOWS\\system32\\cmd.exe;',
spawnargs: [
'/d',
'/s',
'/c',
'"npm ^"install^" ^"--save-exact^" ^"--save^" ^"react^" ^"react-dom^" ^"next^""'
]
}
As you can see error -4058 pops up again
what I have tried:
uninstall and install node and npm (complete uninstall)
adding node, npm and yarn to PATH
run as admin
installing 32bit version of node
installing different versions of node
trying nvm and nvs

Related

How can I generate static files from a pugjs project correctly?

I work with a site that was builded using Pugjs as a template engine and I've been experiencing an error when I try to generate the static files using the command 'npm generate'. The projecto also has other commands but only fails when I try to generate the static files. The error that I have is this one:
` Debugger listening on ws://127.0.0.1:9229/da6b1f3a-77e2-4b7c-993a-9d56b65f637e
For help, see: https://nodejs.org/en/docs/inspector
[app ready] http://localhost:3000
[13:33:28] Finished 'app' after 887 ms
[13:33:28] Starting 'pages'...
[13:33:28] 'pages' errored after 7.74 ms
[13:33:28] Error: spawn wget ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[13:33:28] 'generate' errored after 4.45 min
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weiser#1.0.0 generate: `gulp generate`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weiser#1.0.0 generate 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\JORGE\AppData\Roaming\npm-cache\_logs\2023-01-24T19_33_28_314Z-debug.log`
Hope you help me to find a solution to fix the issue with the command.
PSD: I'm using node 13.12.0
I've tried to generate the static files of the pugjs project but it returns an error

when use vue-cli-service build i got an node error 'Error: write EPIPE'

i got an node error, the cause is to use jenkins to build the projec.
Error: write EPIPE
at process.target._send (internal/child_process.js:841:20)
at process.target.send (internal/child_process.js:712:19)
at callback (/home/jenkins/agent/workspace/dvf.dvf/test-deploy/F-adopt-backoffice/codeDir/node_modules/worker-farm/lib/child/index.js:32:17)
+ npm run build
> widsomfarm_admin_v2#0.1.0 build /home/jenkins/agent/workspace/dvf/F-adopt-backoffice/codeDir
> vue-cli-service build
- Building for production...
WARN A new version of sass-loader is available. Please upgrade for best experience.
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! widsomfarm_admin_v2#0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the widsomfarm_admin_v2#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! /softdata/npm_local_repository/_logs/2022-10-28T09_05_45_429Z-debug.log
events.js:377
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at process.target._send (internal/child_process.js:841:20)
at process.target.send (internal/child_process.js:712:19)
at callback (/home/jenkins/agent/workspace/dvf.dvf/test-deploy/F-adopt-backoffice/codeDir/node_modules/worker-farm/lib/child/index.js:32:17)
at module.exports (/home/jenkins/agent/workspace/dvf.dvf/test-deploy/F-adopt-backoffice/codeDir/node_modules/terser-webpack-plugin/dist/worker.js:13:5)
at handle (/home/jenkins/agent/workspace/dvf.dvf/test-deploy/F-adopt-backoffice/codeDir/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/home/jenkins/agent/workspace/dvf.dvf/test-deploy/F-adopt-backoffice/codeDir/node_modules/worker-farm/lib/child/index.js:55:3)
at process.emit (events.js:400:28)
at emit (internal/child_process.js:912:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
Emitted 'error' event on process instance at:
at internal/child_process.js:845:39
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
Shell Script -- npm run build (self time 1min 10s)
This could be caused by not running npm install before the npm run build in jenkins.
npm install -g #vue/cli
# OR
yarn global add #vue/cli
Also building with CI/CD tools like Jenkins sometimes requires npm install to be replaced with npm ci to make sure doing a clean install of your dependencies. More here npm ci
npm ci
npm run build
...
I get this error too , but only when run build in server environment.
after search about this problem, i found that it because memory limitation ,but unfortunately i couldn't find the right solution .
Maybe this lead will able to help you

Dockerized CRA fails to run because of Craco?

I'm trying to dockerize a CRA and later on integrate in my docker-compose alongside other containers. It seems like the container fails to run because of Craco? Here's the error output.
docker run -p 7070:3000 je12emy/app
> #beextravel/beex-mobile-pwa#0.0.1 start /app
> cross-env SKIP_PREFLIGHT_CHECK=true craco start
events.js:377
throw er; // Unhandled 'error' event
^
Error: spawn craco ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn craco',
path: 'craco',
spawnargs: [ 'start' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #beextravel/beex-mobile-pwa#0.0.1 start: `cross-env SKIP_PREFLIGHT_CHECK=true craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #beextravel/beex-mobile-pwa#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! /root/.npm/_logs/2021-08-20T18_52_28_750Z-debug.log
This is my dockerfile.
FROM node:14-alpine
# set working directory
WORKDIR /app
# install app dependencies
COPY package.json .
RUN npm install
RUN npm install cross-env -g
# add app
COPY . ./
# start app
CMD ["npm","run","start"]

npm start throwing error when trying to create a react app

I am new to web development using react. So, i did the following -
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
But, it is throwing a error which are as follows:
E:\Study\React-course\React-app\my-app>npm start
> my-app#0.1.0 start E:\Study\React-course\React-app\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.5/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from E:\Study\React-course\React-app\my-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:291
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.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! C:\Users\asus\AppData\Roaming\npm-cache\_logs\2020-07-20T07_10_52_845Z-debug.log
E:\Study\React-course\React-app\my-app>
Instead of using this (npm install -g create-react-app create-react-app) try creating react app using ( npx create-react-app my-app)
And for more clarification follow this
https://create-react-app.dev/docs/getting-started/
Please do not write a special character on your local system folder

Create-react-app not working at "npm start" even though correct npm/node version [duplicate]

This question already has answers here:
npm start issues with react-scripts 3.4.0
(5 answers)
Closed 2 years ago.
I am learning react following this tutorial. I got an error about not having a start script which, using my text editor I added to the package.json file. Now I don't really know how to fix what my new error is.
Updated my package-json file, uninstalled and reinstalled create-react-app, made new react-app folder, read through stack overflow. start it manually with "npx react-scripts start".
My npm -v (6.7.0) and node -v (12.16.0)
File directory tree of react-app
node_modules
list of folders that were added upon making folder using create-react-app
public
favicon.ico
index.html
manifest.json
src
index.js
.gitignore
package.json
package-lock.json
README.md
Error:
circulating#CLAPP-T460-22 MINGW64 ~/Desktop/react-app (master)
$ npm start
> react-app#1.1.0 start C:\Users\circulating\Desktop\react-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.16/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\circulating\Desktop\re act-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-app#1.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app#1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\circulating\AppData\Roaming\npm-cache\_logs\2020-06-07T01_ 12_36_919Z-debug.log
Add C:\Windows\System32 to the global PATH environment variable.
or
reinstall your npm with a different react script version. Simply go to your folder in command and reinstall like this:
npm install react-scripts#2.1.8
npm start

Resources