Cannot find module 'json5' on initial run
See original GitHub issueπ bug report
On a brand new project, running either one of the following commands would result in the error (see Current Behavior section) from the command line
parcel ./src/index.html
npm run dev
π Configuration (.babelrc, package.json, cli command)
package.json
{
"name": "dummy-project",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "parcel ./src/index.html",
"build": "parcel build ./src/index.html/"
},
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"parcel-bundler": "^1.10.3"
}
}
.babelrc
{
"presets": [
"env",
"react"
]
}
src/index.js
console.log('ready')
src/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="root"></div>
<script src="./index.js"></script>
</body>
</html>
{
"your": { "config": "here" }
}
π€ Expected Behavior
Parcel should compile without issues.
π― Current Behavior
The initial run would give the following error. However if I ^C and re-run the command it compiles without issues.
Error:
Cannot find module βjson5β
/path-to/dummy-project/src/index.js: Cannot find module 'json5'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (/path-to/dummy-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/path-to/dummy-project/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:19:13)
at Module._compile (/path-to/dummy-project/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
π Possible Solution
As a workaround for now, I simply ^C and re-run the command. And itβll be fine after that.
π¦ Context
I am using the following repo that I came up with a few days ago to scaffold the project:
https://github.com/midnightcodr/create-with-parcel
π» Code Sample
π Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 1.10.3 |
| Node | v8.12.0 |
| npm/Yarn | 6.4.1 / 1.12.3 |
| Operating System | Mac Mojave 10.14.1 |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located underΒ ...
Read more >json5 - npm
Start using json5 in your project by running `npm i json5`. There are 3330 other projects in the npm registry using json5.
Read more >json5 | Yarn - Package Manager
JSON5 is an extension to the popular JSON file format that aims to be easier to write and maintain by hand (e.g. for...
Read more >json5 - PyPI
A Python implementation of the JSON5 data format. ... pip install json5 ... There are a few other more minor extensions to JSON;...
Read more >JSON5 β JSON for Humans | JSON5
JSON5 is an extension to the popular JSON file format that aims to be easier to write and maintain by hand (e.g. for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK fixed my issue I had to update
"babel-loader": "^8.0.4"to"babel-loader": "^8.0.5"so @midnightcodr why donβt you try to addbabel-loader@8.0.5to your project and try again.Just discovered a solution to the problem I have. All I have to do is to install
json5explicitly before I donpm run dev. See https://github.com/midnightcodr/create-with-parcel/commit/9fc45caafd4118b1c0e1a02d0b1074b4dfad4519 for details