为什么 npm start 不运行电子应用程序? [英] Why doesn't npm start run electron app?

查看:19
本文介绍了为什么 npm start 不运行电子应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 package.json 中有几个电子应用程序的以下内容:

 "name": "my-app",版本":1.0.0",描述": "","main": "main.js",脚本":{开始":电子."},

当我在 app 文件夹中执行 npm start 时,相应的应用程序就会运行.使用 npm start 时,我刚刚开始为我的所有电子应用程序获得以下输出:

<块引用><块引用>

电子.

module.js:471
抛出错误;^

错误:找不到模块./"
在 Function.Module._resolveFilename (module.js:469:15)
在 Function.Module._load (module.js:417:25).
在 Module.require (module.js:497:17)
在需要(内部/module.js:20:19)
在对象.(/Users/me/electron/my-app/node_modules/.bin/electron:3:16)
在 Module._compile (module.js:570:32)
在 Object.Module._extensions..js (module.js:579:10)
在 Module.load (module.js:487:32)
在 tryModuleLoad (module.js:446:12)
在 Function.Module._load (module.js:438:3)
npm 错误!代码生命周期
npm 错误!错误号 1
npm 错误!m1@1.0.0 开始:电子 .
npm 错误!退出状态 1
npm 错误!
npm 错误!在 m1@1.0.0 启动脚本处失败.
npm 错误!这可能不是 npm 的问题.有
上面可能有额外的日志输出.

但是,我可以在命令行上成功执行以下任一操作:

电子 main.js电子.

有人知道是什么破坏了 package.json 脚本吗?还是有其他建议?

解决方案

删除node_modules文件夹,然后运行npm install.

I have the following in package.json for several electron apps:

  "name": "my-app",  
  "version": "1.0.0",  
  "description": "",  
  "main": "main.js",  
      "scripts": {
        "start": "electron ."
      },

When I'd do npm start in the app folder, the corresponding app use to run. I just started getting the following output for all of my electron apps when using npm start:

electron .

module.js:471
throw err; ^

Error: Cannot find module './'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25).
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/me/electron/my-app/node_modules/.bin/electron:3:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! m1@1.0.0 start: electron .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the m1@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is
likely additional logging output above.

However, I can do either of the following successfully on the command line:

electron main.js
electron .

Anyone know what might have broken the package.json script? Or some other suggestions?

解决方案

Delete the node_modules folder and then run npm install.

这篇关于为什么 npm start 不运行电子应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆