diff --git a/config/env.js b/config/env.js index d98f22fd69..dee22df369 100644 --- a/config/env.js +++ b/config/env.js @@ -1,7 +1,11 @@ const path = require('path'); +const fs = require('fs'); if (process.env.FREECODECAMP_NODE_ENV !== 'production') { const envPath = path.resolve(__dirname, '../.env'); + if (!fs.existsSync(envPath)) { + throw Error('.env not found, please copy sample.env to .env.'); + } require('dotenv').config({ path: envPath }); } diff --git a/docs/how-to-setup-freecodecamp-locally.md b/docs/how-to-setup-freecodecamp-locally.md index c2c1e5d3cb..3eec0897bf 100644 --- a/docs/how-to-setup-freecodecamp-locally.md +++ b/docs/how-to-setup-freecodecamp-locally.md @@ -191,12 +191,10 @@ This step will install the dependencies required for the application to run: **Docker Build:** ```shell -npm run docker:init -npm run docker:install -npm run docker:seed +npm run docker:run-once ``` -Each of the Docker commands above will take some time to complete. You should wait for each command to fully complete before running the next. +There is a lot to install, this step may take a few minutes. You will also need to install a few npm packages outside of Docker. You can skip this step if you are only running the app locally and will not use git. diff --git a/libcimp_index_js.patch b/libcimp_index_js.patch deleted file mode 100644 index b8f8299cfd..0000000000 --- a/libcimp_index_js.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/index.js b/index.js -index 61bf354..c00dc03 100644 ---- a/index.js -+++ b/index.js -@@ -156,7 +156,7 @@ class Installer { - ) - return BB.join( - this.checkLock(), -- stat && rimraf(path.join(this.prefix, 'node_modules')) -+ stat && rimraf(path.join(this.prefix, 'node_modules/*')) - ) - }).then(() => { - // This needs to happen -after- we've done checkLock() diff --git a/package.json b/package.json index cbbc5f7e00..be6070f882 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,11 @@ "develop": "npm-run-all ensure-env -p develop:*", "develop:client": "cd ./client && npm run develop", "develop:server": "cd ./api-server && npm run develop", + "docker:run-once": "npm run docker:init && npm run docker:install && npm run docker:seed", "docker:clean": "docker-compose run -u root --rm freecodecamp bash -c \"rm -rf **/node_modules/* **/node_modules/..?* **/node_modules/.[!.]* node_modules/* node_modules/..?* node_modules/.[!.]*\"", "docker:develop": "docker-compose up client api-server", "docker:init": "docker-compose run -u root --rm freecodecamp bash change_volumes_owner.sh && docker-compose run -u root --rm client bash -c \"cd .. && bash change_volumes_owner.sh\" && docker-compose run -u root --rm api-server bash -c \"cd .. && bash change_volumes_owner.sh\"", - "docker:install": "docker-compose run -u root --rm freecodecamp bash patch_npm_and_install.sh", + "docker:install": "docker-compose run --rm freecodecamp npm ci", "docker:seed": "docker-compose run --rm freecodecamp npm run seed", "docker:test": "docker-compose -f docker-compose.tests.yml run --rm tests bash", "docker:test:init": "docker-compose -f docker-compose.tests.yml run -u root --rm tests bash change_volumes_owner.sh", diff --git a/patch_npm_and_install.sh b/patch_npm_and_install.sh deleted file mode 100644 index e32d3d3a2e..0000000000 --- a/patch_npm_and_install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -patch /usr/local/lib/node_modules/npm/node_modules/libcipm/index.js < libcimp_index_js.patch -su node -c "npm ci"