Every Time Require new Port Number in ReactJs Local Server - javascript

I am a beginner in ReactJS and I was working on a project and notice a strange thing happened to me every time.
Whenever I shutdown my local server and returned after some time to relaunch the app in the browser by npm start. It doesn't relaunch the app every time I have to give a new port number.
I am sure this is not the right behavior, I'm sure I am doing something wrong.
The error is shown every time in the start script which is below
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /home/vidit/React/codevolution/public ENOSPC
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
at createFsWatchInstance (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/home/vidit/React/codevolution/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:482:16)
at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! codevolution#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the codevolution#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! /home/vidit/.npm/_logs/2020-06-24T13_55_30_728Z-debug.log
vidit#PyPiper:~/React/codevolution$

You are hitting the file watch limit. There is a limit to how many files a process can watch.
Try this
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

It seems like you still have processes from the old local server still hanging around and listening on those ports.
Make sure there is no serverprocess in taskmanager

This error can be solved by two methods either we can specify some other PORT for doing so
You can make a .env file in the root and within this
PORT = <some port number> // PORT = 4001
or you can increase the limit by this
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Tested

Related

can't run my node js project on my cpanel

Run NPM Install
returncode: 126
stdout:
> zenitcouture#1.0.0 start /home/zenitcou/zenitcouture
> nodemon app.js
stderr:
npm WARN lifecycle The node binary used for scripts is /home/zenitcou/nodevenv/zenitcouture/10/bin/node but npm is using /opt/alt/alt-nodejs10/root/usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
sh: /home/zenitcou/zenitcouture/node_modules/.bin/nodemon: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! zenitcouture#1.0.0 start: `nodemon app.js`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the zenitcouture#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! /home/zenitcou/.npm/_logs/2021-10-09T17_17_22_982Z-debug.log
the above is my code. I'm trying to upload it to my cpanel and run it but i keep getting this error. I've stopped the app, and restarted it, the same error.
An error occured during installation of modules. The operation was performed, but check availability of application has failed. Web application responds, but its return code "500 Internal Server Error" or content type before operation "text/html; charset=UTF-8" doesn't equal to contet type after operation "text/html; charset=UTF-8".
i also get this error above if i dont stop the app before installing npm

Node.js app not deploying correctly on Heroku

My repository: https://github.com/jacklemasters/tech-blog
The app works locally on my machine, but I cannot seem to figure out why it will not work on Heroku. I have attempted completely moving the code, a new repository, nothing seems to help.
Here are the error logs I am receiving from Heroku:
2021-10-04T14:32:52.833339+00:00 app[web.1]: npm ERR! tech-blog#1.0.0 start: node server.js
2021-10-04T14:32:52.833414+00:00 app[web.1]: npm ERR! Exit status 1
2021-10-04T14:32:52.833484+00:00 app[web.1]: npm ERR!
2021-10-04T14:32:52.833533+00:00 app[web.1]: npm ERR! Failed at the tech-blog#1.0.0 start script.
2021-10-04T14:32:52.833601+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-04T14:32:52.847732+00:00 app[web.1]:
2021-10-04T14:32:52.847831+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-04T14:32:52.847916+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-10-04T14_32_52_834Z-debug.log
2021-10-04T14:32:53.006395+00:00 heroku[web.1]: Process exited with status 1
2021-10-04T14:32:53.089213+00:00 heroku[web.1]: State changed from starting to crashed
edit: I understand it could be something with my packages, but on my side I see them as installed. Still at a loss!
You are using libraries that you didn't import into the package.json with npm.
Example: npm install express-session
Other thing that is wrong is to upload the .dotenv file to GitHub. Use the .gitignore to avoid it and configure the heroku envorinment variables. See more here: https://devcenter.heroku.com/articles/config-vars

why npm start giving ELIFECYCLE error reactjs [duplicate]

I'm trying to learn react, so I have this sample code for the full-stack react voting app, and I am trying to get it to work but after running npm install followed by npm start I receive the following error when I run npm start can anyone help me with this issue:
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server"
npm ERR! node v7.5.0
npm ERR! npm v4.3.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! voting_app#1.1.0 server: `live-server --public --
host=localhost --port=3000 --middleware=./disable-browser-cache.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the voting_app#1.1.0 server script 'live-server --
public --host=localhost --port=3000 --middleware=./disable-browser-
cache.js'.
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 voting_app
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! live-server --public --host=localhost --port=3000 --
middleware=./disable-browser-cache.js
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls voting_app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_581Z-
debug.log
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! voting_app#1.1.0 start: `npm run server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the voting_app#1.1.0 start script 'npm run server'.
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 voting_app
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run server
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls voting_app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_655Z-
debug.log
Here is my package.json:
{
"name": "voting_app",
"version": "1.1.0",
"author": "Fullstack.io",
"scripts": {
"go": "open http://localhost:3000; npm run server",
"e2e": "nightwatch",
"test": "./node_modules/.bin/concurrently -k 'npm run server' 'npm
run e2e'",
"start": "npm run server",
"server": "live-server public --host=localhost --port=3000 --
middleware=./disable-browser-cache.js"
},
"private": true,
"devDependencies": {
"concurrently": "2.2.0",
"live-server": "git://github.com/acco/live-server.git"
},
"dependencies": {
"semantic-ui": "git://github.com/Semantic-Org/Semantic-
UI.git#27d58a01793b66318478fbc5b6676804d22d065d"
}
}
And finally my log file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm#4.3.0
3 info using node#v7.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle voting_app#1.1.0~prestart: voting_app#1.1.0
6 silly lifecycle voting_app#1.1.0~prestart: no script for prestart, continuing
7 info lifecycle voting_app#1.1.0~start: voting_app#1.1.0
8 verbose lifecycle voting_app#1.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle voting_app#1.1.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1#global/bin:/Users/ItsMeMrLi/.rvm/rubies/ruby-2.3.1/bin:/Users/ItsMeMrLi/.cargo/bin:/usr/local/Cellar/smlnj/110.74/libexec/bin:/usr/local/bin:/Users/ItsMeMrLi/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Downloads/geckodriver:/usr/local/bin:/Users/ItsMeMrLi/.rvm/bin
10 verbose lifecycle voting_app#1.1.0~start: CWD: /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
11 silly lifecycle voting_app#1.1.0~start: Args: [ '-c', 'npm run server' ]
12 silly lifecycle voting_app#1.1.0~start: Returned: code: 1 signal: null
13 info lifecycle voting_app#1.1.0~start: Failed to exec start script
14 verbose stack Error: voting_app#1.1.0 start: `npm run server`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:192:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:192:7)
14 verbose stack at maybeClose (internal/child_process.js:890:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid voting_app#1.1.0
16 verbose cwd /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
17 error Darwin 16.4.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.5.0
20 error npm v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error voting_app#1.1.0 start: `npm run server`
23 error Exit status 1
24 error Failed at the voting_app#1.1.0 start script 'npm run server'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the voting_app package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error npm run server
24 error You can get information on how to open an issue for this project with:
24 error npm bugs voting_app
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls voting_app
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Step 1: $ npm cache clean --force
Step 2: Delete node_modules by $ rm -rf node_modules (rmdir /S /Q node_modules in windows) folder or delete it manually by going into the directory and right-click > delete / move to trash. If you are not updating your packages you can delete the package-lock.json file too.
Step 3: npm install
To start again,
$ npm start
This worked for me. Hopes it works for you too.
PS: Still if it is there, kindly check the error it is displaying in red and act accordingly. This error is specific to node.js environment.
Cleaning Cache and Node_module are not enough.
Follow this steps:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
npm install
It works for me like this.
I resolve this error running following code
npm cache clean
then delete node_modules directory from my project structure manually or with following command
rm -rf node_modules
After That install dependencies again using
npm install
first i ran:
npm run clean
(even though it came with errors)
Then i deleted the node_modules folder and ran
npm install
This seems to have solved the problem.
I was getting similar error messages on a 16.04 Ubuntu instance with DigitalOcean while running npm run build on an app made with create-react-app (link). I upgraded the instance from 512MB RAM to 1GB ($5/mo to $10/mo) and then the script was able to run.
I post this here to point out that you may get this error due to resource limitations, which I didn't really see explained elsewhere on issue pages and SO answers. And nothing I saw in the error logs pointed me in this direction.
Change access in node_modules directory
chmod -R a+rwx ./node_modules
This solution is for Windows users.
You can open the node.js installer and give the installer some time to compute space requirements and then click next and click remove. This will remove node.js from your computer and again reopen the installer and install it in this path - C:\Windows\System32
or
Cleaning Cache and Node_module will work.
Follow this steps:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
npm install
Faced this exact problem,
for me it worked by deleting package-lock.json and re-running npm install
If that doesn't resolve it try
delete package-lock.json
npm cache clean --force
npm install
npm start
Delete node_modules and package-lock.json, and then run npm install. It worked perfectly here(run command below inside project root):
rm -rf node_modules && rm ./package-lock.json && npm install
I was getting this npm ERR! code ELIFECYCLE error while running a build. Clearing the cache and removing the package-lock.json files did not fix it.
In my case there was an Angular build running on a Docker image that was causing this. The root cause turned out to be running the build on Docker in MacOS, which runs the Docker inside a Linux VM, and has by default 2GB memory allocated.
Giving Docker more memory fixed this issue for me. Have to say, the error message could have been quite a bit more clear..
A helpful answer for me was Call retries were exceeded exception while ng build
workaround: Remove the lock file.
rm .\package-lock.json
source: https://github.com/mapbox/node-pre-gyp/issues/298 (floriantraber)
React Application: For me the issue was that after running npm install had some errors.
I've went with the recommendation npm audit fix. This operation broke my package.json and package-lock.json (changed version of packages and and structure of .json).
THE FIX WAS:
Delete node_modules
Run npm install
npm start
Hope this will be helpfull for someone.
npm install --unsafe-perm
worked for me. See https://docs.npmjs.com/. The --unsafe-perm parameter lets you run the scripts from the package instalation as root. The problem in my case was that some depandencies failed to install.
This solution fixed the error in Win10.
Please install globally npm install -g node-pre-gyp
i tried to solve this problem with this way
rm -rf node_modules && rm ./package-lock.json && npm install
But for me its not work.
I just restart my machine and its working perfectly.
Am Linux user ,Machine HP.
I recommend you update your node version to the latest node version recommended by your application or for short update your node version. I encountered this same problem using node version 11.1 but my application was recommending atleast version 10.x.x or 12.x.x
I tried all the suggested reply on this thread but non seemed to work for me untill only when i updated my node version to the recommended latest version .i.e. version 12.16.3 then my application ran.
I just wanted to do run npm run dist to apply some changes for SCSS files, but after hours of suffering, here's what worked for me:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
sudo npm install npm#latest -g this will upgrade npm to latest version
npm audit fix --force
npm upgrade --force
npm install
After these I could finally compile SCSS files successfully with npm run dist.
Check for port availability as well if you encounter below message :
Error: listen EACCES 127.0.0.1:8080
at Object._errnoException (util.js:999:13)
at _exceptionWithHostPort (util.js:1020:20)
at Server.setupListenHandle [as _listen2] (net.js:1362:19)
at listenInCluster (net.js:1420:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1535:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:102:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
A possibly unexpected cause: you use Create React App with some warnings left unfixed, and the project fails on CI (e.g. GitLab CI/CD):
Treating warnings as errors because process.env.CI = true.
[ ... some warnings here ...]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Solution: fix yo' warnings!
Alternative: use CI=false npm run build
See CRA issue #3657
(Ashamed to admit that it just happened to me; did not see it until a colleague pointed it out. Thanks Pascal!)
I'm using ubuntu 18.04 LTS release and I faced the same problem I tried to clean cache as above suggestions but it didn't work for me. However, I found another solution.
echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
npm start
I run this command and it started to work
In my case, I actually ran into this error "code ELIFECYCLE" in a Jenkins job. I tried to clean npm cache but it didn't work and also checked the memory of the Jenkins build server which looks okay. Then, I found the compiling of the react project actually failed in Jenkins but not in my local or when manually running the build on the Jenkins build server, and Jenkins also mentioned "Treating warnings as errors because process.env.CI = true". It looks like the warnings in my project cause the error on Jenkins. Therefore, I changed CI to true in the Jenkins job for now. That actually fixed the build error of Jenkins before I cleared those warnings.
Try to reinstall the cli package globally. In my case, I was trying to test a Vue.js tutorial when I get the same error message. The other thing I did was run the vue command again but this time using webpack-simple and that is why I am not sure wich one solved the problem but now it is working.
The port is probably being used by another application, try listing and see if it's your application:
lsof -i:8080
You can kill the process of this port:
lsof -ti:8080 | xargs kill
I've been bothered by this issue for a long time. For me, the version of node was the problem.
My npm and node were 6.1.0 and 8.11.3, respectively. However, I didn't realize that I had updated my node accidentally to 12.*.*.
It then began to install GCX stuff whenever npm i, which was unnecessary before.
I downgraded my node to 8 and it worked!
Its weird but it works for me
Go to
control panel -->System and Security--> System --> Advanced System
Security--> Environment Variables
In Environment Variable popup you will edit the user variable PATH and add "C:\Windows\System32" value as semicolon separated to the existing value.
Not but not least restart the Machine.
I did follow steps, it works:
1.
npm cache clean --force
remove theĀ package-lock.jsonĀ file
restart my WebStorm
Usually killall node command fixes mine.
Resolved like this:
# chown -R <user>: node_modules
Make sure to use the latest npm version while installing packages using npm.
While installing JavaScript, mention the latest version of NodeJS. For example, while installing JavaScript using devtools, use the below code:
devtools i --javascript nodejs:10.15.1
This will download and install the mentioned NodeJS version. This worked for me.
I was issuing the npm start command with the folder of the project opened at Sublime Text. Closing ST and restarting the server did the work for me.

Creating a new angular project with ng new

When I try to create a new Angular 4 project with 'ng new myProject', the project folder, sub folders and files are created,
but I also always get these errors:
npm ERR! path c:\projects\hello-world\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir
npm ERR! Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR! { Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, rmdir \'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rmdir',
npm ERR! path: 'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I open the Node.js command prompt as Administrator when I issue the ng new command.
I am using Win7 Pro. I have install the following successfully and without any errors. The ng -v returns the following:
-Angular CLI: 1.5.0
-Node: 8.9.0
-OS: win32 x64
-Angular:
npm -v returns: 5.5.1
I give my user account, based on the 'whoami' results, full admin permissions to the myProject folder, the C:\Users\myAccount\AppData\Roaming\npm folder and %APPDATA%\npm-cache folder.
I also perform a 'npm cache verify'.
But I still get the above errors on the ng new command.
How do I correct these errors? Or can I ignore these errors?
If you still run into this problem, one reason you might be running into this is that you installed your CLI tools (#angular/cli) using either 'sudo npm install -g #angular/cli' or as root, from the 'sudo su - root' command, then simply 'npm install -g #angular/cli', and your problem seems to arise whenever you're not logged in and calling an 'ng' command as root or with 'sudo'. This makes sense, but it always causes some kind of insufficient permission related error; and it's not even your fault.
You can easily try to fix or mitigate this serious error by creating and saving a dot-file named '.npm-global' in your home directory ('~/'), then running the command, npm config set prefix '~/.npm-global'.
Then, simply include the line in either /etc/profile or ~/.profile, export PATH=~/.npm-global/bin:$PATH, and run 'source /etc/profile' or 'source ~/.profile' to finalize it. [1]
After that, simply remove anything Node, like 'node_modules/', 'package-lock.json', just all of it.... Then, try installing your NPM packages again -- this time, without using 'sudo' and without root signed in.
https://docs.npmjs.com/getting-started/fixing-npm-permissions

Missing script: start when deploying nodejs to heroku

so I am trying to deploy my nodejs application to heroku.
I have defined the start script in package.json
"scripts": {
"test": "./node_modules/.bin/mocha -r mocha-cakes",
"start": "rm -r -f database/test.db && node app.js",
"start-win": "del database\\test.db && node app.js"
}
I have also added web: rm -r -f database/test.db && node app.js to the Procfile
However my dyno still crashes with the following log error:
2016-06-25T12:27:58.216435+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-25T12:28:00.503447+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-25T12:28:00.502867+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-25T12:28:00.504156+00:00 app[web.1]: npm ERR! npm v3.8.6
2016-06-25T12:28:00.503707+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-25T12:28:00.506550+00:00 app[web.1]: npm ERR! missing script: start
2016-06-25T12:28:00.506746+00:00 app[web.1]: npm ERR!
2016-06-25T12:28:00.506912+00:00 app[web.1]: npm ERR! <https://github.com/npm/npm/issues>
2016-06-25T12:28:00.516583+00:00 app[web.1]:
2016-06-25T12:28:00.516795+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-25T12:28:00.516913+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-06-25T12:28:00.506796+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-25T12:28:00.505628+00:00 app[web.1]:
2016-06-25T12:28:01.445657+00:00 heroku[web.1]: Process exited with status 1
2016-06-25T12:28:01.461079+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-25T12:28:01.461867+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-25T12:28:04.433811+00:00 heroku[web.1]: Starting process with command `npm start`
I have checked with the other SO questions and none of the answers have solved my problem. I have tried everything that the other posts have recommended, but haven't found any success yet.
Here is the link to my repo if you want to see the source code.
In the /database/database.js file after creating the tables if those not exists, there is a db.run query that reads that XML file.
db.run('INSERT OR IGNORE INTO managers (username, password) VALUES ("admin","admin")', function(){
//
// Dear fellow coder:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 3
//
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
//
// Magic, Do not touch
//initialise the table values from log file
// I want to read the xml file after the database tables have been created. HACK HACK!!!
$this.readLogFile();
console.log('Loaded Data from XML document');
});
I'm not sure what's the reason besides testing that you have this in your deployed code. I suppose the reason you want to delete the DB once deployed is that you only need it in testing.
Since Heroku does not seem to like rm -r -f database/test.db, I would suggest you to comment this out for deployment or as a more elegant solution add an if statement before calling this DB query that runs it only if you have a TESTING environment variable with a boolean value of true. You should also delete rm -r -f database/test.db from your start script.
The other problem with your approach is that the start script runs even before the XML file gets imported, so any manipulation with the db in the start script would not delete it.
Instead, you could also create a query that you call in app.js every time you start your server. That query should empty the whole DB. But why to read it and delete it, when you can just not read it at all.

Categories

Resources