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
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" }
}
Parcel should compile without issues.
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)
As a workaround for now, I simply ^C and re-run the command. And it'll be fine after that.
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
| 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|
If I initialize my project with [email protected], I can not reproduce the problem. So it seems it's an issue with the current 1.10.3 version (haven't tested any versions between 1.9.7 and 1.10.3).
Perhaps install json5 it might be a failed autoinstall
Sent with GitHawk
That's not the cause @DeMoorJasper. The folder node_modules/json5 exits before I run npm run dev for the first time. As I said, once I got the errror, I can ^C and run again without issues.
Are you still having this issue?
I can verify that I am having the same problem. I am using "parcel-bundler": "^1.11.0", and I see that json5 is installed but when it the CI/CD is performing a netlify preview deploy it fails with
1:26:16 PM: success Saved 10 new dependencies.
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹溾攢 [email protected]
1:26:16 PM: 鈹斺攢 [email protected]
1:26:17 PM: 馃毃 /opt/build/repo/src/index.jsx: Cannot find module 'json5'
1:26:17 PM: at Function.Module._resolveFilename (module.js:548:15)
1:26:17 PM: at Function.Module._load (module.js:475:25)
1:26:17 PM: at Module.require (module.js:597:17)
1:26:17 PM: at require (/opt/build/repo/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
1:26:17 PM: at Object.<anonymous> (/opt/build/repo/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:19:13)
1:26:17 PM: at Module._compile (/opt/build/repo/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
1:26:17 PM: at Object.Module._extensions..js (module.js:664:10)
1:26:17 PM: at Module.load (module.js:566:32)
1:26:17 PM: at tryModuleLoad (module.js:506:12)
1:26:17 PM: at Function.Module._load (module.js:498:3)
1:26:17 PM: error Command failed with exit code 1.
1:26:17 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This is on a public repo I have if you wish to analyze it further:
https://app.netlify.com/sites/tool-belt/deploys/5c4af1f6cb69cd000935b1bd
https://github.com/george-haddad/tool-belt/pull/23
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 add [email protected] to your project and try again.
Had same problem. Adding babel-loader fixed.
Closed as it has been fixed. (updating babel-loader should fix this)
Still happening to me even after installing [email protected] explicitly. Keep in mind the issue I have is that npm run failed with the json5 error on the initial run and it runs successfully if I ^C and run again. Sorry I was not able to follow this issue closely because I've been abroad for a few months.
Just discovered a solution to the problem I have. All I have to do is to install json5 explicitly before I do npm run dev. See https://github.com/midnightcodr/create-with-parcel/commit/9fc45caafd4118b1c0e1a02d0b1074b4dfad4519 for details