I have been working on this React project, since a few months without having come across this error. I haven't made any changes in the location of the index.html file in the project tree, which is why I can't explain this error.
I have tried the following measures without success:
changing the location of public folder
changing the location of contents of public folder
changing the location of package-lock.json
changing the location of package.json
npm install
npm install react-scripts --save
Please find the error displayed in the terminal:
Could not find a required file.
Name: index.html
Searched in: /Users/Sujay/Documents/Documents/Learn Web Development the Hard Way/lacapsule/project/Dark Sky Map Bitbucket/darkskymap_frontend/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend#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! /Users/Sujay/.npm/_logs/2019-08-06T07_12_22_366Z-debug.log
Expected result : React project should launch without any issue.
Actual result: Error message in terminal mentioned above.
index.html has been moved/removed from the /public directory
Does your project have an index.html file in the public directory?
If not you can get the one that Create React App uses here
It should be in <your project root>/public/index.html
If you are using Git for version control it will be able to tell you if something was moved or removed.
Run git status to view changed files
Your public folder might be missing, just create another app using create-react-app and copy paste the public folder in this directory
I had the exact same problem. Both my package-lock and package.json were outside of the root folder. Once I moved them into the root folder it started up just fine.
In my case, I have accidentally deleted the public directory so it couldn't find the index.html file
Related
I am working through the Frobshop sample project for django-oscar.
The django-oscar documentation is rather terse regarding customizing assets, and the unresolved bug I reported for manage.py oscar_fork_statics just adds to the confusion. This is my (failed) attempt at copying files manually and compiling the assets.
I installed Frobshop in /var/work/django/frobshop/.
I installed a virtual environment for django-oscar in /var/work/django/oscar/, so the asset directory for the distribution is found within that directory, in lib/python3.8/site-packages/oscar/static/oscar/. The README.rst file in that directory said When building your own project, it is not recommended to use these files straight from the package. Rather, you should take a static copy of the ``oscar/static/oscar`` folder and commit it into your project.
Seemed straightforward, so I typed:
$ cd /var/work/django
$ mkdir frobshop/frobshop/static/
$ cp -a lib/python3.8/site-packages/oscar/static/oscar/* frobshop/frobshop/static/
Next, README.rst said: You can compile the static assets from the root of the project using a make target: make assets.
$ make assets
make: *** No rule to make target 'assets'. Stop.
Hmm, that did not work. Is https://github.com/django-oscar/django-oscar/blob/master/Makefile the proper Makefile, I wonder, and where should it be located?
$ wget -O frobshop/static/Makefile \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/Makefile
Running make assets gave me an error message complaining about a missing package.json, so I grabbed it from django-oscar also.
$ wget -O frobshop/static/package.json \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/package.json
Seemed like I should run make from the new frobshop/frobshop/static/ directory:
$ (cd frobshop/static/; make assets)
Many files were installed, then eventually this message appeared:
found 3 vulnerabilities (2 moderate, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm run build
> django-oscar#3.0.0 build /var/work/django/frobshopCamille/frobshop/static
> gulp copy && gulp scss
[11:32:39] No gulpfile found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! django-oscar#3.0.0 build: `gulp copy && gulp scss`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the django-oscar#3.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! /home/mslinn/.npm/_logs/2021-02-19T16_32_39_097Z-debug.log
make: *** [Makefile:29: assets] Error 1
I do not know what to do with that error. I see a directory in django-oscar called gulpfile.js. Should I copy that somewhere also?
README.rst went on to say: If you make changes to Oscar's assets in development, you can run ``npm run watch`` to automatically watch and compile changes to them.
$ (cd frobshop/static/; npm run watch)
Of course, that just yields the same error message as before.
The instructions for compiling assets (using make assets, which runs Gulp tasks) mentioned in src/oscar/static_src/oscar/README.rst are actually only meant for when developing/packaging django-oscar itself. We will try to make the documentation more clear.
For a project/shop based on django-oscar, you only need to run ./manage.py collectstatic, to use Oscar's static files without modification, as mentioned here: https://django-oscar.readthedocs.io/en/latest/howto/how_to_handle_statics.html#customising-statics
To modify and override Oscar's static files, you in addition need to run ./manage.py oscar_fork_statics, to copy Oscar's static files into your project. The command is currently broken, but we are working on a fix: https://github.com/django-oscar/django-oscar/pull/3657
I am new to React js, While using npm start after install the react not working,I tried every process but no use. Thanks in advance
Error
cricdost#0.1.0 start C:\xampp\htdocs\cd-web
react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.41.2"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\xampp\htdocs\node_modules\webpack (version: 4.39.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\xampp\htdocs\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cricdost#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cricdost#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\XSC-10261\AppData\Roaming\npm-cache_logs\2020-02-20T04_56_31_650Z-debug.log
I had faced the same error. The solution that I found is to do the step-6 as described in Error message. That is to delete "webpack" folder of node_module folder under your root projects directory. For example
Assume that you installed "npm install create-react-app" in D:\Projects folder.
And then you ran "npx create-react-app firstproject" in D:\Projects folder. So, your actual react project folder is "D:\Projects\firstproject".
So, what I want to tell is don't delete "webpack" folder in "D:\Projects\firstproject\node_module" directory. Instead, delete "webpack" folder in "D:\Projects\node_module" directory.
And then, you can run "npm start" command in your actual react project directory "D:\Projects\firstproject".
I hope, this will work for you.
I have installed npm and grunt. In the command line, I have navigated to my project's directory, and, initiated a package.json file. My problem is, it seems to only generate part of the file. It definetely generates the package.json file, but it only asks for name and version and irrespective of what I put it first presents this:
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "Grunt Js": Tags may not have any characters that enco
deURIComponent encodes.
About to write to C:\Users\t.steiner\Desktop\Lynda Training\Grunt Js\package.jso
n:
{
"name": "",
"version": ""
}
Is this ok? (yes)
and then this:
Is this ok? (yes) yes
npm ERR! Callback called more than once.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\t.steiner\AppData\Roaming\npm-cache\_logs\2017-11-30T13_58
_26_759Z-debug.log
C:\Users\t.steiner\Desktop\Lynda Training\Grunt Js>
Have I messed up the instillation of either of these items?
I think this issue fits quite well :
https://github.com/npm/npm/issues/17830
I want to put my one of my own repositories as a dependency to a project I am working on. Right now I am using NPM link to do that.
Also, I'd like it to prompt me for my username and password instead of putting that
kind of data in my repository when I use npm install. How do I do that? It doesn't do that now.
I want the content of the repository to show up as their own folder
The problem is when I run npm install it gives me a bunch of error messages from NPM. So I've tried two things. First I tried cloning a public repo from github:
Public Repo Github
SO in package.json, I used the ssh like this:
"dependencies": {
"repo_name": "git#github.com:ownername/reponame.git#84876fa5aasf55fssfsfafsa"
},
^Note that data is fake. The # is a commit hash.
It gave me this error when I ran npm install:
Warning: Permanently added the RSA host key for IP address '$IPADDRESS' to the list of known hosts.
Permission denied (publickey)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Code 128
Then I tried HTTPS, again with a commit hash:
"dependencies": {
"repo_name": "https://github.com/ownername/reponame.git#84876fa5aasf55fssfsfafsa"
},
It worked.....kind of. It seemed to install all the depencies from the repo in the link
but didn't clone the repo in the link to repo_name, it didn't seem to clone anything.
So I decided to try a different repo. One without any dependencies of its own. I used the HTTPS....
it didn't work.
I got these errors:
npm ERR! addLocal Could not install /tmp/npm-11929-4791330b/git-cache-2278328b/38b944c916c18cd4e004f07f2f476a4bb393ff8e
npm ERR! Linux 4.8.0-58-generic
npm ERR! argv "$nodepathname" "$npmpathname" "install"
npm ERR! node v7.0.0
npm ERR! npm v3.10.8
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
Private Repository Bitbucket
When I try my private repository via ssh via provided bitbucket string (with a commit hash), it gives me similar error messages with the other repository, it tells me:
Please make sure you have the correct access rights
npm ERR! code 128
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
It doesn't prompt me for a username or password.
Using https on the private repo (with a commit hash, similar as before) gives me a similar error without prompting me with any username:
remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
npm ERR! code 128
You could use the postinstall hook to initiate the Git clone after npm install:
"scripts": {
"postinstall": "git clone ... node_modules/..."
}
There is no way for npm to prompt for a username or password. Its just not designed to work that way. There is a couple ways to make what your doing work.
1) generate a ssh key(if you haven't already) and add it to your bitbucket.
2) make the private package public(ie open source it)
3) pay for private npm packages and publish a private npm module.
4) make a public npm package if your making open source project. You can still use npm link to link the project to the secondary project to test the packages before publishing. The dependency will be linked based on your not the folder name.
Option 1 and 2 are generally not recommended though. Not using an npm package kind of defeats the purpose of using npm at all. You should try to avoid linking to github directly unless there are extenuating circumstances such as you needed to fork a no longer maintained project and change code.
If you are just trying to avoid paying for private npm modules, personally I would not bother separating out the applications logic into different packages.
Just to all kind of expound. Maybe you are trying to create a module and have never done so before so I will explain that as well. If you have a private or public application (not an npm module, and you are trying to create a public open source npm module and link to it.)
Lets say you have the two folders.
/git/my_application
/git/my_new_npm_module
and your new npm module has the package name "new-module" in package.json. In order to use that in your my_application app, you would need to enter that directory and run npm link on your npm module
cd /git/my_application
npm link ../my_new_npm_module
now within any node file in your my_application app, you can use require('new-module'); to access what is exported from your new npm module.
when your ready to make your package public you simply need to update the version tag in the new modules package.json and type
npm publish
After googling about the specific problem, I found the following link.
link
Hey I've been trying to install "ws" module but when I run npm install ws it gives following error,
npm WARN enoent ENOENT:<Folder name> no such file or directory, open 'G:\Dead Simple\package.json'
Well I searched for solution , everybody answered it as you should have package.json file in your project directory but being a beginner I really don't what to write in that file.How should I resolve it ?
It gives me exactly this output ...
npm WARN enoent ENOENT: no such file or directory, open 'G:\Dead Simple\package.json'
npm WARN Dead Simple No description
npm WARN Dead Simple No repository field.
npm WARN Dead Simple No README data
npm WARN Dead Simple No license field.
You don't need to write anything. At the beginning of your project when you:
npm init
a package.json will be created, listing references to packages you have installed. Installing extra packages add them to your node_modules directory, and adds a reference to your package.json.