I was trying to install Create React App using npm install -g create-react-app . The installation runs well without problem. There was an error that popped up when I entered npm start which is similar to snapshot below. I am using macOS High Sierra version 10.13.x and npm version 13.6.4.
Even though it says "Successfully created my-app", cd my-app and then npm start running the command in console shows following lines of errors that goes like,MODULE_NOT_FOUND.
Do anyone knows that version of npm has a issue installing create react app in Mac, please help.
i.e. >
internal/modules/cjs/loader.js:628
throw e;
^
Error: No valid exports main found for '/Users/Nirmala1/React/my-app/node_modules/postcss-safe-parser/node_modules/postcss'
at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)
at applyExports (internal/modules/cjs/loader.js:502:14)
at resolveExports (internal/modules/cjs/loader.js:551:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/Nirmala1/React/my-app/node_modules/postcss-safe-parser/lib/safe-parse.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1144:30) {
code: 'MODULE_NOT_FOUND'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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:
Fixed this problem by upgrading node.js to v14.5, i've had v13.5 and v13.6 before on my Mac.Tried to solve by removing create-react-app globally:
npm uninstall -g create-react-app
and using:
npx create-react-app myapp
But it didn't work for me. I installed latest version of node using curl -o- url command to download, like
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash
and to install using nvm install version. nvm install v14.15.1
and npx create-react-app myapp
worked well by loading create react app page in http://localhost:3000/.
I came across the same issue with code: 'MODULE_NOT_FOUND' on Ubuntu. I was using an older version of node at the time. All I had to do was to upgrade to the latest version by using the Node Version Manager nvm
Type in the command line:
nvm install stable
That should get you the latest version and then go back to your react app and do as before npm start.
Related
Creating a new React app in G:\My Drive\projects\portfolio\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ENOTDIR
npm ERR! syscall mkdir
npm ERR! path G:\My Drive\projects\portfolio\my-
app\node_modules\webpack\node_modules
npm ERR! errno -4052
npm ERR! ENOTDIR: not a directory, mkdir 'G:\My
Drive\projects\portfolio\my-app\node_modules\webpack\node_modules'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2023-01-
20T08_59_44_240Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-
dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting my-app/ from G:\My Drive\projects\portfolio
Done.
I'm a front-end Developer. I uninstall the nodejs couple of times and then try these commands: "npm cache clean --force", npm uninstall -g create-react-app then reinstall create-react-app but it doesn't work, also updated the latest version of nodejs, use yarn also but couldn't solve the problem, delete the node_modules but it couldn't work, if anyone here pls help me!
when I try to initialize a react-native project I am getting this error. Anyone know how to resolve this please help
i am using mac
Need to install the following packages:
react-native
Ok to proceed? (y) y
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/react-native
npm ERR! dest /Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-QIQKGFeg
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/react-native' -> '/Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-QIQKGFeg'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/codelanticdeveloper/.npm/_logs/2022-02-16T15_54_46_715Z-debug-0.log
where it says...
directory not empty, rename '/Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/react-native' -> '/Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-QIQKGFeg'
delete the file after the arrow and try again
rm -rf '/Users/codelanticdeveloper/.npm/_npx/7930a8670f922cdb/node_modules/.react-native-QIQKGFeg'
Try deleting all the files in the node modules that end with a similar names, like '*-QIQKGFeg'
I did it manually and it worked for me
I also had this problem and fixed it by:
Deleting the problematic Expo files here per the instructions here I'm trying to reinstall expo-cli package globally with the command sudo npm install --g expo-cli note that I try --force
In the terminal, running nvm install 16.14.0 (this will download the correct Node.js LTS release that is required by Expo)
In the terminal, running brew install watchman (this is required by Expo)
In the terminal, running npm install --global expo-cli (globally downloading Expo again)
In the terminal, running expo init my-app to finally create the new app successfully!
QUESTION: How can I make it so $ echo $PATH returns export PATH=~/.npm-global/bin:$PATH
BACKSTORY:
I did an npm install on terminal (macOS Catalina) and started
to get into a loop about installing expo cli when trying to npm
start. I've since followed instructions here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
had to execute step 5 (from link above) as source ~/.bash_profile
Tried npm start but still running into the loop
Already have npm 6.13.4 installed. However, running npm start results in below. Notice how it says Expo CLI installed but asked to install globally again so the 2nd time I say n:
(base) MacBook-Pro:rn-starter user$ npm start
> # start /Users/user/Desktop/REACT NATIVE/rn-starter
> expo start
This command requires Expo CLI.
Do you want to install it globally [Y/n]? Y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]? n
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # 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/user/.npm/_logs/2020-04-03T14_39_24_884Z-debug.log
Here's what's on line 8 of the log file:
8 verbose lifecycle #~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/user/Desktop/REACT NATIVE/rn-starter/node_modules/.bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/git/bin
I've previously installed Anaconda (several months back) and have uninstalled it using https://docs.anaconda.com/anaconda/install/uninstall/ However, running $ echo $PATH results in
/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/git/bin
QUESTION: How can I make it so $ echo $PATH returns export PATH=~/.npm-global/bin:$PATH
Appreciate any suggestions that can help!
How is your package.json file?
Your npm start must is calling the expo
I had an older version of vue CLI and i want to upgrade to CLI 3, so first what I did is unistall the previous version:
npm uninstall vue-cli -g
Then tried to install:
npm install -g #vue/cli
I got the following error:
npm ERR! Unexpected end of JSON input while parsing near '...ulp-rename":"0.0.33",'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\31089\AppData\Roaming\npm-cache\_logs\2020-02-02T11_48_31_187Z-debug.log
The complete log information can be found here
My node version: v12.14.0
My npm version: 6.13.4
And I tried
npm cache clean --force
but didn't work.
I figured out, if you run command prompt window as an administrator, then first do
npm cache clean --force
then can install successfully.
When I type in "npm install -g react-native-cli" at git bash I get following errors:
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at: npm ERR! https://github.com/npm/npm/issues
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\TOSHIBA İ5\AppData\Roaming\npm-cache_logs\2017-10-19T04_04_05_774Z-debug.log
I have already installed npm and added it's directory to PATH variable and when i type "which npm" at git bash it shows the directory so there is no problem about the installation of npm. But it still gives these errors and I am stuck.
Note: I am following the instructions on https://shift.infinite.red/getting-started-with-react-native-development-on-windows-90d85a72ae65
This could happen in some npm old versions. Make sure you are using an updated one.
npm install -g npm
Some linux distros have old versions of npm and node on their packages and you need to install it manually.
Edit: I just saw you have windows. Nevermind, still the old version could be a problem.