其他分享
首页 > 其他分享> > Error spawn parcel ENOENT

Error spawn parcel ENOENT

作者:互联网

问题

> cross-env NODE_ENV=development parcel build --target node --out-dir ./dist --out-file main.js ./app/main.js

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn parcel ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at one rrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at one rrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn parcel',
  path: 'parcel',
  spawnargs: [
    'build',
    '--target',
    'node',
    '--out-dir',
    './dist',
    '--out-file',
    'main.js',
    './app/main.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cn.gk.mcp.client@0.1.0 build-main-dev: `cross-env NODE_ENV=development parcel build --target node --out-dir ./dist --out-file main.js ./app/main.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cn.gk.mcp.client@0.1.0 build-main-dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/geekchief/.npm/_logs/2021-07-14T06_08_32_534Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cn.gk.mcp.client@0.1.0 dev: `cross-env NODE_ENV=development npm run build-main-dev && npm run build-renderer-dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cn.gk.mcp.client@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/geekchief/.npm/_logs/2021-07-14T06_08_32_588Z-debug.log

解决

从网上找了一圈答案,也没有碰到合适的问题,因为导致这个问题的原因有很多,所以大家的想要的解决方案都不一样!

没办法,自己耐下心来慢慢解决吧!

重点是出在这句话上:

Error: spawn parcel ENOENT

通过在NPM官网上查找cross-env包的介绍,发现它有个依赖是spawn,所以安装了cross-env就必然有spawn,那么parcel是什么?

然后到百度上一搜索原来这货是个Nodejs包,然后我就检查我的package.json发现没有这个关键词,后来又通过参考的源码查找发现少依赖了两个包,最后如下解决:

npm install --save-dev parcel-bundler
npm install --save-dev parcel-plugin-asset-copier

标签:spawn,npm,parcel,ERR,--,js,ENOENT,main
来源: https://blog.csdn.net/y1bkkf/article/details/118788734