Reputation: 65
I want to eject my react app,so I use code:npm run eject
in cmmand line.But it told me I failed.And these are all logs:
Remove untracked files, stash or commit any changes, and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] eject: `react-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] eject 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\Pigpigever\AppData\Roaming\npm-cache\_logs\2017-08-
14T09_03_14_398Z-debug.log
Can anyone tell me how to do ?
Upvotes: 4
Views: 15576
Reputation: 352
You have to follow these steps:
git add .
You must have to commit before install eject: git commit -m "save before ejecting"
run eject: if you use yarn, you should type this on your terminal: yarn eject or npm run eject
one config folder will be added to your project, and inside this folder, you will find one file called "webpack.config.js". searching "css-loader" or type (Ctrl+f) for searching specific words. you will find below code in this file.
{
loader: require.resolve('css-loader'),
options: cssOptions,
}
change it by:
{
loader: require.resolve('css-loader'),
options: {
modules: {
mode: "local",
localIdentName: "[name]_[local]_[hash:base64:5]"
},
import: true,
importLoaders: true
}
}
The above steps worked for me. Hopefully, it will also work for you.
Enjoy
Upvotes: 0
Reputation: 1
m ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/red/Desktop/react-course/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/red/Desktop/react-course/package.json'
npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent
If someone facing this issue then just do this:-
cd your project name (for e.g react-assignment)
npm run eject
Upvotes: 0
Reputation: 902
When you use 'create-react-app', it prevents you from ejecting your app without first having committed any outstanding changes to Git. That is the sole reason for the error. Go to your github account create a repository, clone it to your base system . then use 'npm-run-eject'. Mine worked with this. I hope your problem gets resolved too :)
Upvotes: 1
Reputation: 15
git init
git add .
git commit -m "some msg"
yarn eject
or
npm run eject
Upvotes: 1
Reputation: 842
I had the same issue. I did the following to fix it.
rm -rf .gitignore
rm -rf .git
finally
npm run eject
Ejected successfully! :)
Upvotes: 0
Reputation: 175
Please commit all the changes you have done and then retry to eject using the command - 'npm run eject'
Upvotes: 0
Reputation: 4230
You can use:
git add .
git commit -am "Save before ejecting"
And try it again
Upvotes: 4
Reputation: 35817
That error message isn't massively clear (in fact, there's an open issue on GitHub to improve it).
create-react-app
prevents you from ejecting your app without first having committed any outstanding changes to Git - this is so that if ejecting breaks things (or if you just decide you've made a mistake and want to go back), you're able to restore your project to how it was before.
As the error message says - to get the command to work, you'll need to:
.gitignore
).Upvotes: 14