Expo Cannot Find Module after reinstall - javascript

I'm having issues getting expo to start. It tries to open dev tools and dev tools will not open and gives me this error:
Cannot find module 'C:\Users\charl\AppData\Roaming\npm\node_modules\expo-
cli\node_modules\#expo\image-utils\build\index.js'. Please verify that the
package.json has a valid "main" entry
Error: Cannot find module
'C:\Users\charl\AppData\Roaming\npm\node_modules\expo-
cli\node_modules\#expo\image-utils\build\index.js'. Please verify that the
package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:227:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:364:18)
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:597:27)
at Function.Module._load (internal/modules/cjs/loader.js:526:27)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\#expo\xdl#55.0.4\src\AssetUtils.js:6:1)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
This is for a react-native application, using NPM, Node, a Windows 10 machine.
I've tried reinstalling expo with npm and yarn, but i cant get it to work. I looked and saw in the package.json file the 'main' key has a value of 'node_modules/expo/AppEntry.js'. Before this happened i was having trouble with expo that it told me that expo cant be recognized so i messed around with environment variables until it worked. Now this. Thank you guys for any help

Try running
npm install -g expo-cli --force

Was having this same issue when using Windows Powershell or CMD.exe. Was able to get passed it by using Git Bash. Try running npm install -g expo-cli from a MINGW64 terminal (ex: Git Bash)

"node_modules" folder copy/paste
from C:\Users\charl.npm-global to C:\Users\charl\AppData\Roaming\npm\
npm i

I had the same problem. I sort out using two step
first download the Git Bash and installed it , once it was installed open as administrator and wrote the code
npm install -g expo-cli --force

Related

Cannot find module '#mdx-js/mdx' - Gatsby

After the last update of today i'm getting this error. I'm using no MDX in my project howsoever..
npm run develop produces this issue, does someone has some knowledge about this?
internal/modules/cjs/loader.js:979
throw err;
^
Error: Cannot find module '#mdx-js/mdx'
Require stack:
- /Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/transform-recipe-mdx.js
- /Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/renderer/index.js
- /Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/validate-steps.js
- /Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/recipe-machine/index.js
- /Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/graphql-server/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/transform-recipe-mdx.js:12:35)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/transform-recipe-mdx.js',
'/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/renderer/index.js',
'/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/validate-steps.js',
'/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/recipe-machine/index.js',
'/Users/mikey/Sites/Gimmix/node_modules/gatsby-recipes/dist/graphql-server/server.js'
]
}
Problem is solved with the latest update(s): šŸ˜
gatsby#2.24.5
(gatsby-plugin-sharp#2.6.33)
(gatsby-source-contentful#2.3.43)
(gatsby-transformer-remark#2.8.34)
delete your cache
gatsby clean
Be sure to also update your gatsby-cli: npm i -g gatsby-cli
delete your node_modules & packages for a clean install
rm -rf node_modules package-lock.json
last but not least
npm install --save
and test your building proces
npm run develop
I would recommend downgrading to your latest stable version of your Gatsby dependency (to v2.24.37). It seems to be a common issue in ^2.24.54 versions. As you may guess, although you are not using the #mdx-js/mdx package, it's a dependency used by Gatsby itself.
In the upgrade process for any package, when a dependency is upgraded doesn't mean that all their sub-depenencies work because of the needs of each project. It may take a few days/weeks to work for all packages. That's why you should ensure in a gatsby dev and gatsby build that the project works before committing and pushing anything to the repository.
If you haven't committed the upgrade, just rollback the tracked files (git checkout . or git reset --hard), remove your node_modules and run a npm install command to keep the project in your stable running version.
If you have committed your files, run npm install gatsby#2.24.37 to downgrade your Gatsby version (or fix it in your package.json) and run a npm install again.
I saw in your comments that you have the dependency in your package.json but you are not using it. In that case remove it by npm uninstall #mdx-js/mdx.
Running yarn add #mdx-js/mdx fixed it for me.
You first make sure that all dependencies are installed properly.
You can check that is this module installed or not by importing import {<name>} from '#mdx-js'
If it doesn't break it means that it is installed already.
Or if it breaks then run npm install to install all the listed dependencies.
You can move forward and check that this package has that file or data that you want.
You can check this with import {<name>} from '#mdx-js/mdx'. You can also check this with navigating to node_modules/#mdx-js/mdx directory. You will find some names of data you can use, functions or objects etc. Name must match from one of the data type else you have a typo when you are importing something.
Note: this is a general debugging approach for node_modules
run yarn run build and fix those errors. That fixed my problem!

How to fix Cannot find module 'typescript' in Angular 4?

I generated Angular 4 app 3 weeks ago using the #angular/cli. After 2 weeks, I tried to run it with the command line ng serve but I am prompted an error below:
Cannot find module 'typescript'
Error: Cannot find module 'typescript'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\mypc\Documents\Angular Projects\my-angular-app\node_modules\#angular\cli\models\config\config.js:5:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Do you have any idea how to fix this? Thanks.
For me just running the below command is not enough (though a valid first step):
npm install -g typescript
The following command is what you need (I think deleting node_modules works too, but the below command is quicker)
npm link typescript
This should do the trick,
npm install -g typescript
I was able to solve this problem by removing node_modules then running npm install
If you don't have particular needs, I suggest to install Typescript locally.
NPM Installation Method
npm install --global typescript # Global installation
npm install --save-dev typescript # Local installation
Yarn Installation Method
yarn global add typescript # Global installation
yarn add --dev typescript # Local installation
I had a similar problem when I rearranged the folder structure of a project. I tried all the hints given in this thread but none of them worked.
After checking further I discovered that I forgot to copy an important hidden file over to the new directory. That was
.angular-cli.json
from the root directory of the #angular/cli project. After I copied that file over all was running as expected.
Run: npm link typescript if you installed globally
But if you have not installed typescript try this command: npm install typescript
If you use yarn instead of npm, you can install typescript package for that workspace by running:
yarn add typescript
or you can install it globally by running:
sudo yarn global add typescript
to be available for any project.
I had the same problem. If you have installed first nodejs by apt and then you use the tar.gz from nodejs.org, you have to delete the folder located in /usr/lib/node_modules.
I had a very similar problem after moving a working project to a new subdirectory on my file system. It turned out I had failed to move the file named .angular-cli.json to the subfolder along with everything else. After noticing that and moving the file into the subdirectory, all was back to normal.
Run 'npm install' it will install all necessary pkg .
If you have cloned your project from git or somewhere then first, you should type npm install.
The best way is to do: npm install or npm i
this way all dependencies will be added.
I had this same problem using npm run start-dev as configured my package.json ("start-dev": "nodemon src/index.ts"). When i used nodemon src/index.ts in cmd work just fine, but to use npm run start-dev i had to use npm link typescript, it solve the problem.

I installed Node.js but I can't use npm on windows

I have installed node.js. Node seems to be working properly, however, npm is not being found, as you can see below.
C:\Users\jpdrc>node -v
v6.5.0
C:\Users\jpdrc>node hello.js
node is installed!
C:\Users\jpdrc>npm -v
module.js:457
throw err;
^
Error: Cannot find module 'strip-ansi'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\jpdrc\AppData\Roaming\npm\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\string-width\index.js:2:17)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
I have tried multiple solutions as the ones presented:
1- Windows -installed node.js but npm not found
2- Installing Node.js (and npm) on Windows 10
I have no idea what to try next
Thanks for the assistance
Here are my variables under path
As suggested below I have used where npm
C:\Users\jpdrc>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
Steps for solving the above issue:
Check that you have added the path of node in environment variable "path"
If it is there then check that npm is there in the directory which you have added in the path.
If npm is there in the required folder then go to CMD and then go to directory where npm is installed and try to run the version command again. If still you are getting the same issue then there could be two possibilities:
a. Installation is incorrect, try installing again
b. There could be proxy issue due to which packages are not getting downloaded
There cannot be any other issue.
You should be able to run the npm -v in the git bash terminal window. If you don't even have the git-bash app, then download and install git on your Windows.

Error at module.js:341 when trying to add android platform to ionic from command line

I am going to use the Ionic framework to work on hybrid app development, so I installed all the necessary dependencies (node.js, cordova, etc.) and followed their Getting started section. Step number 3 simply involves running the following command within the app directory:
> ionic platform add android
However midway during the execution I got the following error:
module.js:341
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\james.bonello\AppData\Roaming\npm\node_modules\cordova\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I ran > npm update first and tried again to see if the update fixes any missing dependencies and such but the problem persisted.
So, as the error clearly states, the module 'config-chain' is missing so I next ran
> npm install config-chain
While that did install the module, the error somehow still persisted (identical to the previous one). I am not sure what to do next and I cannot understand why npm is not recognizing the 'config-chain' module now. Any ideas?
From what I can see, the missing package config-chain is a dependency of the global package cordova.
You should re-install cordova:
npm cache clean
npm uninstall cordova -g
npm install cordova -g
IF the problem persists, you have to manually install the package inside cordova's modules:
C:> cd Users\james.bonello\AppData\Roaming\npm\node_modules\cordova
C:> npm install config-chain
I did npm install and it worked .

n module breaks npm

After I switch from one node.js version to another with n module - https://github.com/visionmedia/n/, my npm is broken...
MacBook-Pro-Dmitri:~ dmitri$ npm --version
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at /usr/local/bin/npm:19:11
at Object.<anonymous> (/usr/local/bin/npm:87:3)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
then i'm installing npm again as it was adviced here - https://github.com/visionmedia/n/issues/101
curl https://npmjs.org/install.sh | sh
npm begins to work..
but then i do another switch for node version:
n 0.8.22
and npm now is broken again with the same error.
it's very annoying.. do I need to install npm manually after every version switch?!
Are there different global package repositories for different versions?
Perhaps either that package needs to be re-installed globally sudo npm install -g or the package manage cache cleaned sudo npm cache clean after switching version(s).
Node and npm should get bundled together these days, if you are a frequent version changer like me. You can try installing node with NVM
https://github.com/creationix/nvm
This will help you differentiate packages in different node versions. Just do a npm install after the switch.
PS: The current node version is quite stable right now. You can just use the current version instead of 0.8.22
You could try installing npmlog manually: npm install -g npmlog
I had the same problem and couldnā€™t find a solution.
It seems that n is less well maintained than nvm so I completely removed node following these steps and re-installed it using nvm.
(And node now includes npm)
I had same problem on windows. I uninstalled node, deleted everything from its install directory and re-installed. After restarting command line, I got npm working again.

Categories

Resources