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!
Related
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
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 have the following problem. I install uuid with npm install -g uuid.
When I try to run the following code:
var uuid = require("uuid");
console.log(uuid.v1());
an exception is thrown:
module.js:339
throw err;
^
Error: Cannot find module 'uuid'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (d:\CodingProjects\HTML\TestJavascript.js:16:12)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
If I install the module locally with npm install uuid it works fine.
But why is that? What should I do, to make my global packages working?
I tried to download it from Language & Frameworks -> Javascript -> Libraries, but I still get an exception if I don't install it locally for my project.
Thanks in advance.
The reason is in how npm installs packages.
When you run npm install -g <package>, you tell npm to install the <package> globally. This works when you want to use the package as a command line tool, like, for example, Gulp:
$ npm install -g gulp
$ cd path/to/project
$ gulp
However, this does not work when you want to depend on a package.
To depend on a package, you should install it locally, i. e. in the project directory. This is one of the npm’s key benefits: local installation makes managing dependencies and upgrading them much easier for you. The npm install command without -g flag is dedicated exactly for that. When you run
$ npm install uuid
in, say, foo directory, a foo/node_modules directory is created, and uuid module is installed there. After that, you could create a .js file in the foo directory (or any its subdirectory), require the uuid module from it, and everything will work.
As to WebStorm: downloading a library from Language & Frameworks → Javascript → Libraries does not actually download an npm package, it just downloads and installs the library type definitions. Type definitions help WebStorm build better autocompletion when you use a library in your code.
If you would like to use your global packages, all you need to do is create a link between your global package from within your local directory.
This is also known as creating a symbolic link (symlink).
So, running the "npm link uui" in your local directory would allow you to use the global package wihout having to download it into your local directory.
If you analyze the local directory you'll notice that a (linked) folder has been created, meaning it is merely a pointer to the global package.
So, in short, if you want to use global packages, then "npm link" is the way to do it.
I'm trying to create a fix for a an NPM package that I rather enjoy, Wintersmith. However, Wintersmith is supposed to be globally installed (executable with wintersmith <command>) and I can't seem to run it from the root of a project where I have it installed locally manually with git clone <my fork url> with something like node ./node_modules/wintersmith/bin/wintersmith without receiving path errors:
module.js:340
throw err;
^
Error: Cannot find module '../lib/cli/'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (F:\web\wintersmith\node_modules\bin\wintersmith:3:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
The only way I can figure to properly develop and test this is by manually replacing my globally installed Wintersmith package with my forked version and then executing commands using that version to test whether or not my changes are working.
Is there some workflow step that I'm missing when working with/developing global NPM packages?
You should use npm install git:// instead git clone
Install your fork like this:
npm install git://github.com/YOURNAME/wintersmith.git
You can also install it as global module use -g:
npm install -g git://github.com/YOURNAME/wintersmith.git
NodeJS eats an environment variable NODE_PATH. You can make use of that besides PATH.
This document describes it better:
http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
I can execute wintersmith like this, without having to install it globally:
$ git clone https://github.com/jnordberg/wintersmith.git
$ cd wintersmith
$ npm install # This installs all dependencies I need for the next step.
$ npm run-script prepublish # Run the prepublish script which compiles sources to ./lib
$ bin/wintersmith
I get the usage message that it gives when there is nothing passed as arguments.
When creating a node package that is meant to be installed globally it is possible and desirable to design it so that it can be run and tested without having to install it. I was surprised that wintersmith would not be designed this way.
Generally speaking, if I had to deal with a node package that cannot be tested without being installed globally, I'd call it "defective". (Maybe there are exceptions but such exceptions are rare and they should be justified in the package's documentation.)
So, generally, if I had to deal with a package that cannot be run and tested without being installed globally, I'd look for a package providing equivalent functionality which can be run without being installed globally, or fix the faulty package.
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.