I believe I get this almost every time I try to install a dependency:
$ gatsby develop
module.js:491
throw err;
^
Error: Cannot find module 'gatsby/dist/utils/develop'
at Function.Module._resolveFilename (module.js:489:15)
at resolveFileName (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-cli\
node_modules\resolve-from\index.js:17:39)
at resolveFrom (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-cli\node
_modules\resolve-from\index.js:31:9)
at module.exports (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-cli\n
ode_modules\resolve-from\index.js:34:41)
at module.exports.moduleId (C:\Users\s\AppData\Roaming\npm\node_modules\gat
sby-cli\node_modules\resolve-cwd\index.js:4:30)
at Command.<anonymous> (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-
cli\index.js:135:23)
at Command.listener (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-cli
\node_modules\commander\index.js:300:8)
at emitTwo (events.js:125:13)
at Command.emit (events.js:213:7)
at Command.parseArgs (C:\Users\s\AppData\Roaming\npm\node_modules\gatsby-cl
i\node_modules\commander\index.js:635:12)
and while installing a dependency i get these warns, not sure if relevant to the issue:
$ npm install --save styled-components
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\.bin\semver.cmd as it wasn't installed by E:\Front-End Projects\Gatsby\
sebhewelt.com\node_modules\semver
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\.bin\semver as it wasn't installed by E:\Front-End Projects\Gatsby\sebh
ewelt.com\node_modules\semver
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\jspm-registry\node_modules\.bin\semver.cmd as it wasn't installed by E:
\Front-End Projects\Gatsby\sebhewelt.com\node_modules\jspm-registry\node_module
s\semver
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\jspm-registry\node_modules\.bin\semver as it wasn't installed by E:\Fro
nt-End Projects\Gatsby\sebhewelt.com\node_modules\jspm-registry\node_modules\se
mver
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\.bin\browserslist.cmd as it wasn't installed by E:\Front-End Projects\G
atsby\sebhewelt.com\node_modules\browserslist
npm WARN gentlyRm not removing E:\Front-End Projects\Gatsby\sebhewelt.com\node_
modules\.bin\browserslist as it wasn't installed by E:\Front-End Projects\Gatsb
y\sebhewelt.com\node_modules\browserslist
gatsby-config.js
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sass`,
`gatsby-plugin-styled-components`,
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/pages/blog`,
name: 'blog'
}
},
`gatsby-transformer-remark`
]
};
package.json
{
"name": "gatsby-starter-default",
"description": "Gatsby default starter",
"version": "1.0.0",
"author": "Kyle Mathews <[email protected]>",
"dependencies": {
"gatsby": "^1.9.17",
"gatsby-link": "^1.6.15",
"gatsby-plugin-react-helmet": "^1.0.5",
"gatsby-plugin-sass": "^1.0.12",
"gatsby-plugin-styled-components": "^1.0.5",
"gatsby-source-filesystem": "^1.4.12",
"gatsby-transformer-remark": "^1.7.7"
},
"keywords": ["gatsby"],
"license": "MIT",
"main": "n/a",
"scripts": {
"build": "gatsby build --prefix-paths",
"develop": "gatsby develop",
"format":
"prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0",
"gsap": "^1.20.2",
"node-sass": "^4.5.3",
"prettier": "^1.6.1",
"styled-components": "^2.1.2"
}
}
gatsby-node.js
const path = require("path");
exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators;
const postTemplate = path.resolve("src/templates/post.js");
return graphql(`{
allMarkdownRemark {
edges {
node {
html
id
frontmatter {
title
path
}
}
}
}
}`).then(res => {
if (res.errors) {
return Promise.reject(res.errors);
}
res.data.allMarkdownRemark.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: postTemplate
});
});
});
};
Delete node_modules and package-lock.json and run npm install again.
NPM has a bug right now where they delete packages.
Which verson of NPM is recommended? I'd like to avoid the hassle of having to delete and reinstall everything.. Thanks
We recommend Yarn.
The above doesn't seem to work. I even tried deleting package-lock.json and node_modules and running yarn
. Still get the same error.
node 8.5.0
npm 5.5.1
@ChrisSki try also updating the global gatsby-cli
Yup. Solved for now!
Still doesn't work :/
@adamrasheed did you update the global gatsby
and gatsby-cli
npm packages, as well as npm itself?
I had to do all of that, and then delete my package-lock.json
file, my node_modules
folders and then run npm install
again.
@ChrisSki I did that, and installed yarn as well. I got it working, but I'm running a mismatch of yarn/npm right now; its weird.
Most helpful comment
Delete node_modules and package-lock.json and run npm install again.
NPM has a bug right now where they delete packages.