---> Running in 0e34d471598d
> myproject#1.0.0 build /app
> node scripts/build.js
Could not find a required file.
Name: index.html
Searched in: /app/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject#1.0.0 build: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject#1.0.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! /root/.npm/_logs/2021-08-05T14_49_57_665Z-debug.log
The command '/bin/sh -c npm run build ;' returned a non-zero code: 1
##[error]The command '/bin/sh -c npm run build ;' returned a non-zero code: 1
##[error]The process '/usr/bin/docker' failed with exit code 1
So there is the error "can't find file" but actually THERE IS a public directory with the index.html file inside. I don't know why this is happening...
Edit: Im adding the docker file used in config pipe
# -- Base node --
FROM node:13.7-alpine AS build
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
ARG BUILD_ENV
RUN npm run build ;
# -- final build --
FROM nginx:1.17.8-alpine
COPY --from=build /app/build /var/www
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
I notice you are running this on docker, so you did wrong on docker during copy your react app directory to docker container.
You have not added your Dockerfile code here
So we suggest you to fix your dockerfile first. Also check your .dockerignore file and debug getting into docker container, if the directory exist there or not
So your docker file should be similar to this
COPY . ./
RUN npm run build
It should be like this (Not . /app):
# Copy other project files and build
COPY . ./
RUN npm run build
Related
I have a nodejs application and I want to deploy it using docker.
I have the following structure for folders and files
/src
/config
status.js
role.js
index.js
/routes
user.routes.js
product.routes.js
index.js
index.js
Dockerfile
package.json
... other files and folders
the content of src/config/index.js is:
module.exports = {
...require("./status"),
...require("./role"),
};
The content of Dockerfile
FROM node:19-alpine3.16
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i
COPY . .
CMD ["node", "src/index.js"]
when I do docker image build I got the following error
---> Running in 2f2e6c84845b
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /usr/src/app/src/config/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/src/config/package.json'
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! /root/.npm/_logs/2022-12-26T09_17_19_235Z-debug-0.log
The command '/bin/sh -c npm i' returned a non-zero code: 254
I tried to add package.json with empty json to every folder has index.js file and that worked fine. but does that make sense to add package.json to every folder.
Black#DESKTOP-N04CDRI MINGW64 /c/web devlopment/react-chat-application/chat-application (master)
$ npm start
chat-application#0.1.0 start C:\web devlopment\react-chat-application\chat-application
react-scripts start
Could not find a required file.
Name: index.js
Searched in: C:\web devlopment\react-chat-application\chat-application\src
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-application#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-application#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\Black\AppData\Roaming\npm-cache_logs\2021-09-29T15_56_51_774Z-debug.log
Black#DESKTOP-N04CDRI MINGW64 /c/web devlopment/react-chat-application/chat-application (master)
$
you may have deleted index.js file or renamed it.if you are using react-create-app pipeline then you can't rename that or remove this file so make sure it's present in your src folder inside project dir and if you are using git then run git status it will tell you what you had changed.
index.html has been moved/removed from the /public directory
Does your project have an index.js file in the public directory?
If not you can get the one that Create React App uses here
On running a docker build, I get an error with core-js dependencies missing. On running npm's suggested install command, I get another error. I tried to revert to a couple of earlier branches, but no cigar.
The error on docker build . is:
ERROR Failed to compile with 122 errors5:31:56 AM
These dependencies were not found:
* core-js/modules/es6.array.copy-within in ./src/main.js
* core-js/modules/es6.array.fill in ./src/main.js
* core-js/modules/es6.array.find in ./src/main.js
* core-js/modules/es6.array.find-index in ./src/main.js
* core-js/modules/es6.array.from in ./src/main.js
* core-js/modules/es6.array.iterator in ./src/main.js
* core-js/modules/es6.array.of in ./src/main.js
* core-js/modules/es6.array.sort in ./src/main.js
* core-js/modules/es6.array.species in ./src/main.js
* core-js/modules/es6.date.to-primitive in ./src/main.js
...
Along with another hundred similar lines, followed by this suggestion:
To install them, you can run: npm install --save core-js/modules/es6.array.copy-within core-js/modules/es6.array.fill core-js/modules/es6.array.find core-js/modules/es6.array.find-index core-js/modules/es6.array.from core-js/modules/es6.array.iterator core-js/modules/es6.array.of core-js/modules/es6.array.sort core-js/modules/es6.array.species core-js/modules/es6.date.to-primitive core-js/modules/es6.function.has-instance core-js/modules/es6.function.name core-js/modules/es6.map core-js/modules/es6.math.acosh core-js/modules/es6.math.asinh core-js/modules/es6.math.atanh core-js/modules/es6.math.cbrt core-js/modules/es6.math.clz32 core-js/modules/es6.math.cosh core-js/modules/es6.math.expm1 core-js/modules/es6.math.fround core-js/modules/es6.math.hypot core-js/modules/es6.math.imul core-js/modules/es6.math.log10 core-js/modules/es6.math.log1p core-js/modules/es6.math.log2 core-js/modules/es6.math.sign core-js/modules/es6.math.sinh core-js/modules/es6.math.tanh core-js/modules/es6.math.trunc core-js/modules/es6.number.constructor core-js/modules/es6.number.epsilon core-js/modules/es6.number.is-finite core-js/modules/es6.number.is-integer core-js/modules/es6.number.is-nan core-js/modules/es6.number.is-safe-integer core-js/modules/es6.number.max-safe-integer core-js/modules/es6.number.min-safe-integer core-js/modules/es6.number.parse-float core-js/modules/es6.number.parse-int core-js/modules/es6.object.assign core-js/modules/es6.object.freeze core-js/modules/es6.object.get-own-property-descriptor core-js/modules/es6.object.get-own-property-names core-js/modules/es6.object.get-prototype-of core-js/modules/es6.object.is core-js/modules/es6.object.is-extensible core-js/modules/es6.object.is-frozen core-js/modules/es6.object.is-sealed core-js/modules/es6.object.keys core-js/modules/es6.object.prevent-extensions core-js/modules/es6.object.seal core-js/modules/es6.object.set-prototype-of core-js/modules/es6.promise core-js/modules/es6.reflect.apply core-js/modules/es6.reflect.construct core-js/modules/es6.reflect.define-property core-js/modules/es6.reflect.delete-property core-js/modules/es6.reflect.get core-js/modules/es6.reflect.get-own-property-descriptor core-js/modules/es6.reflect.get-prototype-of core-js/modules/es6.reflect.has core-js/modules/es6.reflect.is-extensible core-js/modules/es6.reflect.own-keys core-js/modules/es6.reflect.prevent-extensions core-js/modules/es6.reflect.set core-js/modules/es6.reflect.set-prototype-of core-js/modules/es6.regexp.constructor core-js/modules/es6.regexp.flags core-js/modules/es6.regexp.match core-js/modules/es6.regexp.replace core-js/modules/es6.regexp.search core-js/modules/es6.regexp.split core-js/modules/es6.regexp.to-string core-js/modules/es6.set core-js/modules/es6.string.anchor core-js/modules/es6.string.big core-js/modules/es6.string.blink core-js/modules/es6.string.bold core-js/modules/es6.string.code-point-at core-js/modules/es6.string.ends-with core-js/modules/es6.string.fixed core-js/modules/es6.string.fontcolor core-js/modules/es6.string.fontsize core-js/modules/es6.string.from-code-point core-js/modules/es6.string.includes core-js/modules/es6.string.italics core-js/modules/es6.string.iterator core-js/modules/es6.string.link core-js/modules/es6.string.raw core-js/modules/es6.string.repeat core-js/modules/es6.string.small core-js/modules/es6.string.starts-with core-js/modules/es6.string.strike core-js/modules/es6.string.sub core-js/modules/es6.string.sup core-js/modules/es6.symbol core-js/modules/es6.typed.array-buffer core-js/modules/es6.typed.float32-array core-js/modules/es6.typed.float64-array core-js/modules/es6.typed.int16-array core-js/modules/es6.typed.int32-array core-js/modules/es6.typed.int8-array core-js/modules/es6.typed.uint16-array core-js/modules/es6.typed.uint32-array core-js/modules/es6.typed.uint8-array core-js/modules/es6.typed.uint8-clamped-array core-js/modules/es6.weak-map core-js/modules/es6.weak-set core-js/modules/es7.array.includes core-js/modules/es7.object.define-getter core-js/modules/es7.object.define-setter core-js/modules/es7.object.entries core-js/modules/es7.object.get-own-property-descriptors core-js/modules/es7.object.lookup-getter core-js/modules/es7.object.lookup-setter core-js/modules/es7.object.values core-js/modules/es7.promise.finally core-js/modules/es7.string.pad-end core-js/modules/es7.string.pad-start core-js/modules/es7.symbol.async-iterator core-js/modules/web.dom.iterable
and ending in:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend#0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend#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! /root/.npm/_logs/2020-03-24T05_31_56_496Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
I tried running npm's suggestion, which resulted in:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "core-js/modules/es6.array.copy-within" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/orb/.npm/_logs/2020-03-24T05_44_47_462Z-debug.log
I'm quite confused. I'm not sure how I'm missing core-js modules because the last time I ran the build (a couple of days ago), I had not issues. Any idea what's going on here?
Dockerfile:
FROM node:lts-alpine as updraft-frontend-build-stage
#install http server
RUN npm install -g http-server
#make app folder in current directory
WORKDIR /app
#copy package.json and package-lock.json
COPY package*.json ./
#install project dependencies
RUN npm install
#copy in project files & folders
COPY . .
#build app with minification
RUN npm run build
# EXPOSE 8080
# CMD ["http-server", "dist"]
#production stage
FROM nginx:stable-alpine as updraft-frontend-production-stage
COPY --from=updraft-frontend-build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Update:
Tried running the docker build without the cached layers, but no luck there either.
NPM won't install the missing files because they're part of core-js. running
npm i -S core-js#2.5.7
did the trick.
This thread has a few alternative options if you're interested:
Module not found: Error: Can't resolve 'core-js/es6'
----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.13.0...
Using default npm version: 6.12.0
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> nodemon#1.19.3 postinstall /tmp/build_33db88ab97938128199a401d17366aac/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
//REMOVED INSTALLATION TEXT HERE DUE TO CHAR LIMIT
-----> Build
Running heroku-postbuild
> website_setup#1.0.0 heroku-postbuild /tmp/build_33db88ab97938128199a401d17366aac
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
audited 905041 packages in 14.447s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_33db88ab97938128199a401d17366aac/client
> react-scripts build
sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the client#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! /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_454Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! website_setup#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the website_setup#1.0.0 heroku-postbuild 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! /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_470Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Synopsis:
I recently finished MERN stack course and went to go push my build to Heroku but encountered the error above. I first thought it was a visual studio permissions error so I ran vs code with elevated privileges. This, however, did not work.
I've tried and had no success with:
Adding a nodejs script build package to my deployment
Modifying my package.json to incorporate engine which selects the version of node.js to run
Adding .js extensions to the end of the server in the scripts section thinking there may be a simple issue with that
Double checking that my local instance works properly (it does)
Promptly throwing my computer out my window (feels pretty good, but still not working)
Refer to this link to see how to check your file for the correct permissions and how to set them ( Updating file permissions with git-bash on Windows 7 )
sh: 1: react-scripts: Permission denied
So this is a permission issue. Go to the correct path that contains a react-scripts and do a chmod +x react-scripts will solve this issue.
I took a look at you GitHub repo and it seems to be a simple typo in your .gitignore file :
node_module/
config/default.json
And this should be :
node_modules/
config/default.json
Notice the name of node_modules folder ,so a quick fix would be to edit you .gitignore file and put the wright name , then run the following :
git rm -r --cached node_modules
delete node_modules in root directory as well in client/
git commit -am 'ignore node_modules'
And finally push your changes , this should fix the error .
check your package.json => React-script-->
step = 1==> "react-scripts": "(change_currend_version)"
Ex: "react-scripts": "1.0.1" change ==>"react-scripts": "3.4.3"
step = 2==> install ==> npm i
step = 3 ==> npm start
I am having this error message when I try to deploy my application on Heroku. Any suggestions? I can easily deploy my app on localhost but it doesn't work on Heroku.
My Package.JSON is:
{
"name":"tryout",
"version":"0.0.1",
"private":true,
"scripts":{
"start":"node app"
},
"dependencies":{
"express":"3.0.0rc3",
"jade":"*",
"passport":">= 0.1.11",
"passport-local":">= 0.1.3",
"underscore":">= 1.3.3",
"socket.io":">= 0.9.6",
"node-uuid":">= 1.3.3",
"mongoose":">= 3.0.2",
"bcrypt":">= 0.7.1"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
PS: I don't use hiredis at all.
Input command is: git push heroku master
Counting objects: 1731, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1541/1541), done.
Writing objects: 100% (1731/1731), 7.42 MiB | 400 KiB/s, done.
Total 1731 (delta 192), reused 0 (delta 0)
-----> Removing .DS_Store files
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.8.14
Using npm version: 1.1.65
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm WARN package.json socket-app#0.0.1 No README.md file found!
npm WARN package.json jade#0.27.2 No README.md file found!
> hiredis#0.1.14 preinstall /tmp/build_37k5gxae7u8vc/node_modules/hiredis
> make || gmake
cd deps/hiredis && make static
make[1]: Entering directory `/tmp/build_37k5gxae7u8vc/node_modules/hiredis/deps/hiredis'
make[1]: Nothing to be done for `static'.
make[1]: Leaving directory `/tmp/build_37k5gxae7u8vc/node_modules/hiredis/deps/hiredis'
node-waf configure build
Setting srcdir to : /tmp/build_37k5gxae7u8vc/node_modules/hiredis
Setting blddir to : /tmp/build_37k5gxae7u8vc/node_modules/hiredis/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /tmp/node-node-jj2B
'configure' finished successfully (0.056s)
Waf: Entering directory `/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
Waf: Leaving directory `/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
Traceback (most recent call last):
File "/tmp/node-node-jj2B/bin/node-waf", line 16, in <module>
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
prepare_impl(t, cwd, ver, wafdir)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
main()
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
fun(ctx)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
return build_impl(bld)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
bld.compile()
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Build.py", line 268, in compile
os.chdir(self.bldnode.abspath())
OSError: [Errno 2] No such file or directory: '/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
make: *** [all] Error 1
sh: gmake: not found
npm ERR! hiredis#0.1.14 preinstall: `make || gmake`
npm ERR! `sh "-c" "make || gmake"` failed with 127
npm ERR!
npm ERR! Failed at the hiredis#0.1.14 preinstall script.
npm ERR! This is most likely a problem with the hiredis package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make || gmake
npm ERR! You can get their info via:
npm ERR! npm owner ls hiredis
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-347-ec2
npm ERR! command "/tmp/node-node-jj2B/bin/node" "/tmp/node-npm-nN2P/cli.js" "install" "--production"
npm ERR! cwd /tmp/build_37k5gxae7u8vc
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_37k5gxae7u8vc/npm-debug.log
npm ERR! not ok code 0
! Failed to install --production dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git#heroku.com:arcane-sea-8207.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:arcane-sea-8207.git'
It seems hiredis is indirectly needed by express, which you have a release candidate version, which might be the problem. Try to change express to:
"express":"3.x"
Also, make sure you don't commit the node_modules directory to your git repo. Add it to .gitignore!