I get error when running npm start in vs code - node.js

(node:6852) [LRU_CACHE_OPTION_maxAge] DeprecationWarning: The maxAge option is deprecated. please use options.ttl instead
(Use `node --trace-deprecation ...` to show where the warning was created)
> mynodejsapp#0.0.0 start
> node ./bin/www
npm ERR! code ENOENT
npm ERR! syscall spawn C:\Windows\system32\cmd.exe;C:\MinGW\bin
npm ERR! path C:\Users\TECHNOCITY9645075247\Desktop\web designing\myNodejsApp
npm ERR! errno -4058
npm ERR! enoent spawn C:\Windows\system32\cmd.exe;C:\MinGW\bin 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\TECHNOCITY9645075247\AppData\Local\npm-cache\_logs\2022-03-13T10_44_05_635Z-debug-0.logenter code here
this is the error showing in the terminal
my node and npm versions are upto date

Try to reinstall Node.js. Should work as it worked for me.
Uninstalling the Node.js
Clear the npm cache by running the following command in your terminal.
npm cache clean --force
Go to the windows control panel and click on Uninstall a program, select Node.js and click on uninstall tab to uninstall the node and npm successfully.
Restart your system.
Verify if node.js and npm are completely uninstalled from your system using:
node -v
If the above command prints command not found then you’re successfully uninstalled, otherwise look into the below directories and remove the contents manually.
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)

Looks you're facing the problem of using maxAge instead of expires
look at this link Can't set cookie 'expires' or 'maxAge' in Node.js using Express 3.0
Maybe help you for better resolution into the issue.

Try to reinstall Node.js.
Should work as it worked for me.

Try to clean your cache then reinstall Node.js. Should work as it worked for me.

Related

I can't use "create-react-app" ("This is related to npm not being able to find a file.")

I tried every single thing I've found, but I just can't run create-react-app. I tried to uninstall node and install again, use yarn, clean cache, create with "npm init ..." but nothing works.
Microsoft Windows [versão 10.0.19043.1889]
(c) Microsoft Corporation. Todos os direitos reservados.
C:\Program Files (x86)\Windows Resource Kits\Tools>cd C:\Users\user\meu_app
C:\Users\user\meu_app>node -v
v16.17.0
C:\Users\user\meu_app>npm -v
8.18.0
C:\Users\user\meu_app>npx create-react-app myapp
npm ERR! code ENOENT
npm ERR! syscall spawn C:\Users\user
npm ERR! path C:\Users\user\meu_app
npm ERR! errno -4058
npm ERR! enoent spawn C:\Users\user 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\user\AppData\Local\npm-cache\_logs\2022-09-02T19_06_17_314Z-debug-0.log
I have never seen this issue before. npx is distributed with npm 5.2+, so that shouldn't be the issue. It seems your issue is similar to this one Can't install any NPM package, error 4058
Try these steps:
Delete package-lock.json and run NPM again (probably can skip this one if it does not pertain to your issue)
Ensure no other processes of node.js are running (check task manager)
If you are using visual studio code, close it and try running npm install again.
If all else fails, restart your computer.
See thread here: https://github.com/npm/npm/issues/17444
Let me know if that helps; otherwise, I will keep looking.

Windows 11 - npm ERR! errno -4058 - code ENOENT bash

Got this very annoying NPM issue out of nowhere, though I must say I had a few weeks break from playing with my project.
Actual version of core-js.
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\User1\Documents\project11\node_modules\**#angular\cli**
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
This npm ERR! errno -4058 seems to be rather common issue, but I've found no success and am getting a bit worried, I've tried all possible solutions I've found online (below)
Delete package-lock + node modules + npm cache and then run npm install
Use yarn instead of NPM (installation succeeds but can't run project)
Reinstall node and npm completely
Test with different (newest) npm & node versions
Test building only production version
Restart computer
Close all vscode applications etc. that could use npm
Run cmd as admin
Check windows defender if it could block npm
Make sure system32 is correctly set in env. variables
Hox, the erro says angular-cli, but if I somehow manage to get through that, it will just complain about the next library
Edit: Workaround for me seems to be to run npm in git-bash
For some reason I can't use powershell nor CMD anymore to run NPM, but that's not a big issue.
Funny. Before I posted this question, I already had spent well over 5 hours testing everything I found online. Immediately after posting this question, I, just for the sake of it, tested running npm install in "git-bash".
And.. it worked, so if somebody else is having issues with this, try running npm install in git bash https://gitforwindows.org/ instead
And of course you can try the things I tried above

How can I install nodejs manually in Linux from terminal

I have downloaded Nodejs in my Linux VM from nodejs.org, I want to install it from terminal. VM have already installed node v0.12.18 manually by someone else, I don't know how to do that. As I am installing nodejs offline, I should not depend on that whether or not npm installed.
I have tried [location]~ npm install node-v15.6.0-linux-x64.tar.gz
Getting below error
[host#machinename ~]$ sudo npm install node-v15.6.0-linux-x64.tar.gz
npm WARN excluding symbolic link bin/npm -> ../lib/node_modules/npm/bin/npm-cli. js
npm WARN excluding symbolic link bin/npx -> ../lib/node_modules/npm/bin/npx-cli. js
npm ERR! addLocal Could not install /home/usermachinename/node-v15.6.0-linux-x64.tar.g z
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/loc al/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "node-v15.6.0-linux-x64 .tar.gz"
npm ERR! node v0.12.18
npm ERR! npm v2.15.11
npm ERR! path /tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! enoent ENOENT, open '/tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package .json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/usermachinename/npm-debug.log
How can I fix this?
You can't install the file using npm install, but since you already have the compressed file for node, my answer will hopefully help you achieve your goal.
First of all you will have to extract the tar.gz file you have node-v15.6.0-linux-x64.tar.gz, to do so just navigate to the folder where the file placed in then do the below command.
tar xf node-v15.6.0-linux-x64.tar.gz
Since you're using Linux the below command will add the new extracted node to your path.
nano ~/.profile
Add the following lines to the end:
# NodeJS
export NODEJS_HOME=/{path_to_the_extracted_folder}/node-v15.6.0-linux-x64/bin
export PATH=$NODEJS_HOME:$PATH
Please make sure you change {path_to_the_extracted_folder} to the path where you extracted the compressed file in the previous step.
Finally you can click CTRL+C to exit nano, type y then click enter.
To refresh the profile file enter the below code
. ~/.profile
Finally
To make sure everything is working fine check the nodeJs version by entering this command node -v it has to print v15.6.0.
You will not have to worry about the previously installed node version since above steps will change the nodeJs path.

npm (version 5.5.1) install errors

I have installed node version 9.2.0 and npm version 5.5.1
On the command line, I want to install packages:
$ npm install express --save
npm WARN bookstore#1.0.0 No repository field.
npm ERR! path C:\Users\ad\Projects\bookstore\node_modules\bytes
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename
'C:\Users\ad\Projects\bookstore\node_modules\bytes' ->
'C:\Users\ad\Projects\bookstore\node_modules\.bytes.DELETE'
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\ad\AppData\Roaming\npm-cache\_logs\2018-03-
14T06_36_04_014Z-debug.log
What does this mean? Maybe I should uninstall node version 9 and revert to the LTS-version 8? And how to do that in Windows?
Please, I need help; thank you in advance!
EDIT: Could it be caused by a slow internet connection; npm not being able to find a file.?
EDIT 2: I was able to uninstall node version 9.2.0, then installed version 8.10.0 :-( Still the same error messages!
First Use Below Command
touch .npmignore
Then Install Express
npm install express --save
I found a solution, but this is really stupid! Let me explain: I have been using Visual Studio Code for months now, and it's inbuilt command line (bash). Never had any issues with it!
But now; there must be something wrong with VS Code, giving these errors.
I tried an alternative: Git-Bash command window and separately Sublime Text 3. And it works! I could install all dependencies that were needed, without any errors or warnings!
Can someone explain this strange behavior I had using VS Code?

What does the ELIFECYCLE Node.js error mean?

What does ELIFECYCLE mean?
Here's my app code: https://gist.github.com/samholmes/388ca4552c5936b52c5d
When I run the 'blast-emails' command, it will run for a while until shortly crashing with the error:
npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nvm/versions/io.js/v1.6.1/bin/iojs" "/root/.nvm/versions/io.js/v1.6.1/bin/npm" "run" "live"
npm ERR! node v1.6.1
npm ERR! npm v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! emailer#0.0.0 live: `NODE_ENV=production node app.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the emailer#0.0.0 live script 'NODE_ENV=production node app.js'.
npm ERR! This is most likely a problem with the emailer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls emailer
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /apps/emailer/npm-debug.log
The npm-debug.log file is also included in the gist.
I'm looking for one of two answers: What does ELIFECYCLE mean? (or) Why am I getting the error in my application code?
It's basically saying it fails to spawn your process not due to permission but to an error in your script. Source
You don't have any problem executing NODE_ENV=production node app.js ?
One might think this is because outdated versions of npm and node, but it's not the case.
Just as Pierre Inglebert says, if you look into the source you can see that End of lifecycle means the program unexpectedly stopped. This can have various reasons. So it's not a syntax error and not an expected exception/error.
The error appeared to me when a different tool was already using the http port (3000) defined in my node scripts. When you run your node app on port 80, make sure you have stopped Apache webserver (as an example).
In my case, it was because of low RAM memory, when a photo compression library was unable to process bigger photos.
While working on a WordPress theme, I got the same ELIFECYCLE error with slightly different output:
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/7.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.6.0
npm ERR! npm v3.7.3
npm ERR! code ELIFECYCLE
npm ERR! foundationsix#1.0.0 postinstall: `bower install && gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foundationsix#1.0.0 postinstall script 'bower install && gulp build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the foundationsix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install && gulp build
After trying npm install one more time with the same result, I tried bower install. When that was successful I tried gulp build and that also worked.
Everything is working just fine now. No idea why running each command separately worked when && failed but maybe someone else will find this answer useful.
If you came here like I did, after receiving a similar error when trying the React Getting Started guide, you might like to know that the problem could have been caused by not having installed Watchman. Download it here, or install it with Homebrew with brew install watchman and try again: https://facebook.github.io/watchman/docs/install.html
PS: You might want to do a brew update first.
When running Webpack build I was getting similar error because node doesn't understand async await keywords on older versions. I added webpack babel-plugin-transform-async-to-generator and it was solved. This replaces them with promises.
at process._tickCallback (internal/process/next_tick.js:10
4:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ng-contact-manager#0.0.0 sample: `node src/server/dat
a/seed-db.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng-contact-manager#0.0.0 sample script.
npm ERR! This is probably not a problem with npm. There is lik
ely additional logging output above.
npm ERR! A complete log of this run can be found in:
I have the same issue here is how I got solved finally!
the error:
my error from the terminal when i run npm run sample
after correcting my database connection username and password
I was using mlab for my database and under the file .env i forget to properly put the user name and password. When I correct that I works.
> ng-contact-manager#0.0.0 sample /Users/mohammedr.kemal/Downl
oads/Ex_Files_ANGULAR_API_AUTH/Exercise Files/Ch01/01_04/start
> node src/server/data/seed-db.js
connected to mongodb...
connected to mongodb...
2 records inserted.
closing connection...
done.
12 records inserted.
closing connection...
done.
So it might be good to look any data connection we made in our code if we have.
I had the same error after I installed new packages or updated them:
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
...
It helped me to run installation command once again or a couple of times.
After that, the error disappeared.
I had this issue when I was running two projects that had the same set up and I already had one running. This meant that the other project couldn't use that port number. As soon as I stopped the other project running I had no issues.
This issue can also occur when you pull code from git and not yet installed node modules "npm install".
The Windows solution is the same as the Linux sudo answer. Run the npm start (or whatever) as Administrator. I had added a new module to my project. Worked on some machines but on others that were more locked down, not so much. Took a while to figure it out but the new module needed access to "something" that wasn't available without administrator permissions.
I had the same error code when I was running npm run build inside node docker container.
Locally it was working while inside a container I had set option to throw error when there is a warning during compilation while locally it wasn't set. So this error can mean anything that is connected with stopping the process being done by NPM
In my case I generated a similar error when I copied the project over from another directory. some hidden files, like the critical .babelrc, were missing. SO ahhh... make sure you copy all the files!
:)
For me it was a ternary statement:
It was complaining about this line in particular, about the semicolon:
let num_coin = val.num_coin ? val.num_coin || 2;
I changed it to:
let num_coin = val.num_coin || 2;
Likewise, I saw this error as a result of too little RAM. I cranked up the RAM on the VM and the error disappeared.
I found the solution here - https://javahowtos.com/guides/124-docker/418-npm-exit-status-137-when-building-a-docker-image.html
It says - The cause of this specific npm error status usually means that Docker is going out of memory. So, when this happens, the Linux kernel just kills the process.
if you are running on ubuntu, please check your nodejs version. please update the version to the latest and clear the cache and reinstall the modules (npm install) and build.
or otherwise
please upgrade your RAM size and try again. it'll work sure.
First, you will have to remove the npm cache and upgrade to the latest version of the node and npm will resolve the issue.
sudo npm cache clean -f
sudo npm install -g n install n
sudo n stable
The first command will force clean the npm package manager's cache, After the second and third commands, a stable version of the node and npm will be installed. then you can execute npm i and npm run build for creating an optimized production build.
This solution worked for the same error on the npm run build command in nextjs.

Resources