Functioning Flask Project cannot run npm run build, npm deploy, npm start. Fails to run flask project

57 Views Asked by At

project structure . I have a functioning flask project. In the sense that, I run the server two days ago and it ran fine. I was using a virtual environment at the time. I return to the project 2 days later and it is no longer running. I am new to dealing with some of these issues. But i was reading online and I found some sources stating to remove package-json or node_modules. I removed those and tried to install them again using npm i. But I continue to receive the issue:

npm ERR! Missing script: "build"

when running npm build

this is my package-lock-json file

{
  "name": "geoprocessing_engine",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "geoprocessing_engine",
      "version": "1.0.0",
      "license": "ISC"
    }
  }

i am aware that i do not have scripts here, but i am slightly worried that thats not the only issued. I ran flask run and I received this issue:

Error: Could not import 'server'.

and on a seperate attempt also :

File 

"/Users/moisesherrera/Desktop/LocisNet_Software_Dev/gistwebapp/geoprocessing_engine/src/models.py", line 7, in <module>
    from geoalchemy2 import Geometry
ModuleNotFoundError: No module named 'geoalchemy2'

I just feel that for some reason over the course of two days, maybe the virtual environment was deactivated somehow, and now I don't have the original package json files to recover my work. I am just a bit worried because I do not know what to do to get my app running successfully again.

I tried running this scripts:

delete node-modules folder
run command npm cache clean --force
run command npm install
npm i

but tbh i dont know if I even had a node-modules to begin with, This is a flask python only server, I have been using pip3 to install all dependencies and its been working great up to now.

I havent tried manually putting in the script: "npm start" or "npm run build" because I am not sure if those actually even point to anything in my file structure. My files structure is below:

1

There are 1 best solutions below

0
Moises Herrera On

The solutions was simple, I had to activate venv first then run:

FLASK_APP=src.server

After that, I had to install the dependency once more, I ran:

pip3 install geoalchemy3

Note: I was surprised when I saw that I needed to install geoalchemy3 because I had already installed it. This, along with the previous NPM confusion (coming from my React front-end) led me to believe that all of my dependencies were missing. This made the confusion even worse, but in case someone else comes across a similar issue. If one dependency is missing, even if you have already installed it, that does not mean all will be missing.