Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel build throws Unknown error #1752

Closed
Jancat opened this issue Jul 18, 2018 · 10 comments
Closed

Parcel build throws Unknown error #1752

Jancat opened this issue Jul 18, 2018 · 10 comments

Comments

@Jancat
Copy link

Jancat commented Jul 18, 2018

馃悰 bug report

I'm building a vue application with typescript. There is normal when running parcel index.html, but error was thrown in parcel build index.html

馃帥 Configuration (.babelrc, package.json, cli command)

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "jsx": "preserve",
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitReturns": true,
    // "sourceMap": true,
    // "strict": true,
    "target": "es5",
    "paths": {
      "@/*": ["src/*"]
    },
    "lib": ["esnext"]
  },
  "parcelTsPluginOptions": {
    // If true type-checking is disabled
    "transpileOnly": false
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
  "exclude": ["node_modules"]
}

package.json

{
  "name": "finchat-h5-pages",
  "version": "0.1.0",
  "description": "FinChat H5 pages repository.",
  "main": "index.js",
  "private": true,
  "scripts": {
    "lint": "tslint -c tslint.yaml 'src/**/*.ts'; wotan '**/*.vue'",
    "lint:fix": "tslint -c tslint.yaml --fix 'src/**/*.ts'; wotan --fix '**/*.vue'",
    "clean": "rm -rf .cache && rm -rf dist",
    "prestart": "yarn clean",
    "start": "parcel public/index.html",
    "dev": "yarn clean && NODE_ENV=production parcel public/index.html",
    "staging": "yarn clean && NODE_ENV=staging parcel public/index.html",
    "prod": "yarn clean && NODE_ENV=production parcel public/index.html",
    "build": "parcel build public/index.html",
    "prepush": "yarn lint",
    "svg": "vsvg -s ./src/assets/icons -t ./src/components/icons --ext ts --es6",
    "mock": "json-server --watch mock/db.json dist/index.html --static ./dist --port 3004 --routes mock/routes.json"
  },
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "lodash": "^4.17.10",
    "vant": "^1.1.12",
    "vue": "^2.5.16",
    "vue-class-component": "^6.2.0",
    "vue-head": "^2.0.12",
    "vue-hot-reload-api": "^2.3.0",
    "vue-property-decorator": "^7.0.0",
    "vue-router": "^3.0.1",
    "whatwg-fetch": "^2.0.4"
  },
  "devDependencies": {
    "@fimbul/valtyr": "^0.11.0",
    "@fimbul/ve": "^0.11.0",
    "@fimbul/wotan": "^0.11.0",
    "@types/config": "^0.0.34",
    "@types/lodash": "^4.14.111",
    "@types/node": "^10.5.2",r
    "@vue/component-compiler-utils": "^2.1.0",
    "autoprefixer": "^8.6.5",
    "husky": "^0.14.3",
    "json-server": "^0.14.0",
    "node-sass": "^4.9.2",
    "parcel-bundler": "^1.9.4",
    "parcel-plugin-typescript": "^1.0.0",
    "postcss-modules": "^1.1.0",
    "postcss-px-to-viewport": "^0.0.3",
    "prettier": "^1.13.7",
    "ts-import-plugin": "^1.5.4",
    "tslint": "^5.10.0",
    "tslint-config-prettier": "^1.13.0",
    "tslint-eslint-rules": "^5.3.1",
    "tslint-plugin-prettier": "^1.3.0",
    "typescript": "^2.9.2",
    "vue-svgicon": "^3.0.2",
    "vue-template-compiler": "^2.5.16"
  },
  "browserslist": [
    "Android >= 5.0",
    "iOS >= 9"
  ]
}

馃 Expected Behavior

parcel build index.html successfully output dist directory

馃槸 Current Behavior

When execute NODE_ENV=production parcel build index.html and parcel build index.html, the error was thrown:

Unknown error
    at Object.jsonToError (/xxx/node_modules/parcel-bundler/src/workerfarm/errorUtils.js:15:15)
    at Worker.receive (/xxx/node_modules/parcel-bundler/src/workerfarm/Worker.js:150:32)
    at ChildProcess.emit (events.js:182:13)
    at emit (internal/child_process.js:811:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

parcel build index.html works normally. So is the NODE_ENV=production makes the error?

I debug the

let call = this.calls.get(idx);

and log the call error info:

call { method: 'run',
  args:
   [ '/xxx/src/views/product/ProductList.vue',
     false ],
  retries: 0,
  resolve: [Function],
  reject: [Function] }

馃拋 Possible Solution

馃敠 Context

馃捇 Code Sample

馃實 Your Environment

Software Version(s)
Parcel 1.9.7
Node 10.5.0
npm/Yarn Yarn
Operating System Mac OS X
@DeMoorJasper
Copy link
Member

Is this error reproducable? Not sure why this is happening?
Could you make a reproducable example repository?

Unknown error is a bit vague to resolve into an actual cause

@Jancat
Copy link
Author

Jancat commented Jul 19, 2018

The demo repository is here https://github.com/Jancat/parcel-vue-ts-demo.

Because of the issue of parcel build, I had to import vue-cli to build the dist.

@andrewbanchich
Copy link

andrewbanchich commented Jul 19, 2018

@DeMoorJasper I'm getting the same error and found this when trying to figure out why.

Also, I'm not using TypeScript at all.

@DeMoorJasper DeMoorJasper changed the title Parcel build Unknown error at Object.jsonToError Parcel build throws Unknown error Jul 19, 2018
@DeMoorJasper
Copy link
Member

@andrewbanchich Unknown error can pretty much be everything but I'll look into it when I find the time

@DeMoorJasper
Copy link
Member

This is a fairly strange error, for some reason it throws a string instead of an error somewhere. This is the real error message:

Error: Error: Error: Cannot find source file "/Users/demoor/Documents/parcel-vue-ts-demo/src/views/product/ProductList.vue"
    at TypeScriptCompiler.compile (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/parcel-plugin-typescript/build/backend/compiler/tsc.js:24:19)
    at Object.<anonymous> (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/parcel-plugin-typescript/build/backend/worker/launcher.js:28:29)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/tslib/tslib.js:104:62)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at TypeScriptWorker.<anonymous> (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/parcel-plugin-typescript/build/backend/ipc/worker/index.js:27:19)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/tslib/tslib.js:104:62)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at IncomingMessage.res.setEncoding.on (/Users/demoor/Documents/parcel-vue-ts-demo/node_modules/parcel-plugin-typescript/build/backend/ipc/client.js:31:32)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

@andrewbanchich
Copy link

How can I see the "real" error message?

I only get this when building Vue as well, but when I serve it for dev it is totally fine. I just finished porting all the code from Webpack to Parcel, so it would be helpful if I had a way to find out where this error is actually originating.

@andrewbanchich
Copy link

I got it working. I think it was related to #1124 , since I eventually got it to display a real error message.

@DeMoorJasper
Copy link
Member

@andrewbanchich I opened a PR that fixes this issue, like mentioned above. #1761

@Jancat
Copy link
Author

Jancat commented Jul 20, 2018

@DeMoorJasper Could you tell me how to fix the error that Cannot find source file? I had imported parcel-plugin-typescript to configure baseUrl and paths in tsconfig.json.

And it works fine on parcel public/index.html except throw the error UnhandledPromiseRejectionWarning: Error: Error: Error: Could not find file: xxx .

@DeMoorJasper
Copy link
Member

Probably best to report it to parcel-plugin-ts

Sent with GitHawk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants