无法在termux上运行packaging.json定义的脚本

时间:2018-01-09 10:20:11

标签: android node.js termux

我正在设置一个移动节点环境,但我无法弄清楚为什么我无法使用Termux运行package.json中定义的脚本,我在尝试npm run prettier或其他任何其他时都会收到以下错误日志脚本

0 info it worked if it ends with ok
1 verbose cli [ '/data/data/com.termux/        files/usr/bin/node',
1 verbose cli   '/data/data/com.termux/files/usr/bin/npm',
1 verbose cli   'run',
1 verbose cli   'prettier' ]
2 info using npm@5.6.0
3 info using node@v8.9.3
4 verbose run-script [ 'prettier' ]
5 info lifecycle examplepackage@1.0.0~prettier: examplepackage@1.0.0
6 verbose lifecycle examplepackage@1.0.0~prettier: unsafe-perm in lifecycle true
7 verbose lifecycle examplepackage@1.0.0~prettier: PATH: /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/data/data/com.termux/files/home/examplepackage/node_modules/.bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
8 verbose lifecycle examplepackage@1.0.0~prettier: CWD: /data/data/com.termux/files/home/examplepackage
9 silly lifecycle examplepackage@1.0.0~prettier: Args: [ '-c', 'prettier --write  main.js' ]
10 info lifecycle examplepackage@1.0.0~prettier: Failed to exec prettier script
11 verbose stack Error: examplepackage@1.0.0 prettier: `prettier --write main.js`
11 verbose stack spawn ENOENT
11 verbose stack     at ChildProcess.<anonymous> (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
11 verbose stack     at emitTwo (events.js:126:13)
11 verbose stack     at ChildProcess.emit (events.js:214:7)
11 verbose stack     at maybeClose (internal/child_process.js:925:16)
11 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
12 verbose pkgid examplepackage@1.0.0
13 verbose cwd /data/data/com.termux/files/home/examplepackage
14 verbose Linux 3.18.31-perf-g64ca40a-00128-g77c6b6b
15 verbose argv "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/bin/npm" "run" "prettier"
16 verbose node v8.9.3
17 verbose npm  v5.6.0
18 error file sh
19 error code ELIFECYCLE
20 error errno ENOENT
21 error syscall spawn
22 error examplepackage@1.0.0 prettier: `prettier --write main.js`
22 error spawn ENOENT
23 error Failed at the examplepackage@1.0.0 prettier script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

给出以下基本package.json

{
  "name": "examplepackage",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "dependencies": {
    "axios": "^0.17.1"
  },
  "devDependencies": {
    "prettier": "^1.9.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
"prettier": "prettier --write main.js"
  },
  "author": "",
  "license": "ISC"
}

有什么建议吗?提前致谢

1 个答案:

答案 0 :(得分:0)

'npm verify'和'npm audit fix'可以帮助您将其范围缩小到节点的特定uuid,以标识实际的json以及损坏的json,以及可能卸载并重新安装的pkg