taskr
taskr copied to clipboard
A Strange Syntax Error
Why?:
The Code will report a strange Syntax Error, but it will run normally after removing const WORK_SPACE = process.cwd();
Code:
const WORK_SPACE = process.cwd();
export async function test(task){
console.log(';test')
}
export default async function (task) {
console.log("index taskr");
await task.clear('compild');
await task.start('test');
}
ERROR:
export async function test(task){
^^^^^^
SyntaxError: Unexpected token 'export'
at new Taskr (D:/xxxxx/xxxxx/node_modules/taskr/lib/taskr.js:21:39)
at Object.<anonymous> (D:/xxxxx/xxxxx/node_modules/taskr/lib/cli/spawn.js:35:9)
at Generator.next (<anonymous>)
at Generator.tryCatcher (D:/xxxxx/xxxxx/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (D:/xxxxx/xxxxx/node_modules/bluebird/js/release/generators.js:97:49)
ENV: node 12.18.3 packages: "@taskr/clear": "^1.1.0", "@taskr/esnext": "^1.1.0", "@taskr/watch": "^1.1.0", "@vercel/ncc": "^0.27.0", "node-notifier": "^9.0.0", "taskr": "^1.1.0", "typescript": "^4.1.3"
Hi,
Is this the entire file? I think there may be content before/above const WORK_SPACE = process.cwd();
that's affecting this.
Hi,
Is this the entire file? I think there may be content before/above
const WORK_SPACE = process.cwd();
that's affecting this.
Yes,this is all. This is a project that we just initialized.
System: window 10 EE:18363.1316 And: It seems to be because of the system, but why does this happen? I can reproduce this error on win10 computer, but not on Mac
There are only two files: taskfile.js
const WORK_SPACE = process.cwd();
export async function test(task){
console.log(';test')
}
export default async function (task) {
console.log("index taskr");
await task.clear('compild');
await task.start('test');
}
package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "taskr",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"taskr": "^1.1.0"
}
}