After I successfully finished Part One of the Tutorial, I got stuck at the first steps of Part Two.
First, I executed gatsby new tutorial-part-two https://github.com/gatsbyjs/gatsby-starter-hello-world
and npm install --save gatsby-plugin-typography, then I created the gatsby-config.js as it is instructed in the tutorial. After that I tried to execute gatsby develop but it didn't work.
This is the error stacktrace:
````
tutorial-part-two โ โ gatsby develop
module.js:472
throw err;
^
Error: Cannot find module 'gatsby/dist/utils/develop'
at Function.Module._resolveFilename (module.js:470:15)
at resolveFileName (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/resolve-from/index.js:17:39)
at resolveFrom (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/resolve-from/index.js:31:9)
at module.exports (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/resolve-from/index.js:34:41)
at module.exports.moduleId (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/resolve-cwd/index.js:4:30)
at Command.
at Command.listener (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/commander/index.js:300:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)
at Command.parseArgs (/Users/rcanepa/.nvm/versions/node/v7.9.0/lib/node_modules/gatsby-cli/node_modules/commander/index.js:635:12)
````
It seems that the problem appears after executing npm install --save gatsby-plugin-typography. This is the output I got after installing the gatsby-plugin-typography package.
````
tutorial-part-two โ npm install --save gatsby-plugin-typography
npm WARN gentlyRm not removing /Users/rcanepa/Development/studies/gatsby/tutorial-part-two/node_modules/jspm-registry/node_modules/.bin/semver as it wasn't installed by /Users/rcanepa/Development/studies/gatsby/tutorial-part-two/node_modules/jspm-registry/node_modules/semver
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none was installed.
npm WARN gatsby-starter-hello-world@ No repository field.
I am using:
NPM removed all the other packages?!? ๐จ Can you look in node_modules?
This is what I have inside node_modules:
tutorial-part-two โ ls node_modules | wc -l
90
tutorial-part-two โ ls node_modules
autoprefixer find-cache-dir postcss-merge-rules
babel-core front-matter postcss-svgo
babel-generator fstream prop-types
babel-loader gatsby react
babel-plugin-transform-es2015-unicode-regex gatsby-plugin-typography react-dom
babel-preset-env global-prefix react-router
babel-register gray-matter react-router-dom
babel-runtime gray-percentage react-typography
babel-template history redux
babel-traverse http-signature regenerator-runtime
bundle-loader invariant regexpu-core
caniuse-api js-yaml relay-runtime
chunk-manifest-webpack-plugin jspm source-map-resolve
compass-vertical-rhythm jspm-github style-loader
console-polyfill jspm-npm svgo
convert-css-length jspm-registry systemjs-builder
copyfiles loader-utils tar-fs
core-js lodash tar-pack
create-hash lodash.isnumber typography
create-hmac markdown-toc typography-normalize
create-react-class memory-fs url-loader
cross-spawn modularscale warning
css-color-function node-cjsx webpack
css-loader node-pre-gyp webpack-dev-middleware
css-selector-tokenizer normalize-package-data webpack-dev-server
decamelize object-assign webpack-hot-middleware
del parse-unit webpack-validator
diffie-hellman pbkdf2 yaml-loader
extract-text-webpack-plugin pixrem yargs
fbjs pkg-resolve yurnalist
In node_modules from Part One I have 1020 packages installed.
tutorial-part-one โ โ ls node_modules | wc -l
1020
Ugh.
What NPM version are you on?
To fix, delete node_modules and the package-lock.json and run npm install.
Awesome. Now everything works and I can continue =) ...
I am using NPM 5.3.0.
Thanks Kyle!
I think I've seen some similar NPM removing packages due to package-lock.json and things.
Also experienced this, rm -rf node_modules rm package-lock.json and npm install solves it.
same here after installing styled-components plugin. fixed later with a npm i
Any idea on how to solve this error on Netlify? My site builds fine locally, but not on Netlify.
Was using a more recent of NPM locally. You can set NPM_VERSION on Netlify so match things up if you run into the same problem that I did.
@KyleAMathews in node: v8.3.0, the idea can not work . so I rollback to v7.9.0. It works.
nothing solves it for me yet. Is this anything to do with babel?
warning gatsby > [email protected]: ๐ Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
Tried:
node rollback to v7.9.0
rm -rf node_modules rm package-lock.json and npm install
rm -rf node_modules rm package-lock.json and yarn install
I had recently git cloned gatsby and installed that in a directory so i removed that and removed the package version too using npm, re-added using npm
gatsby new deleteme
cd deleteme
gatsby develop
Each time I did a version of rm -rf node_modules rm package-lock.json [then npm or yarn installs]
Always this error message:
bash-3.2$ date
Sat 14 Oct 2017 19:19:25 AWST
bash-3.2$ gatsby develop
module.js:472
throw err;
^
Error: Cannot find module 'gatsby/dist/utils/develop'
at Function.Module._resolveFilename (module.js:470:15)
at resolveFileName (/usr/local/lib/node_modules/gatsby-cli/node_modules/resolve-from/index.js:17:39)
Working now after running:
npm install --global gatsby-cli@latest
from https://github.com/gatsbyjs/gatsby/issues/2455
thanks @jquense
@migs540 thanks that worked for me as well.
Closing out old issues โ thanks for everyone that participated! Please open up new issues if you need more help!
Most helpful comment
Also experienced this,
rm -rf node_modulesrm package-lock.jsonandnpm installsolves it.