【问题标题】:npm start does nothing on windowsnpm start 在 Windows 上什么都不做
【发布时间】:2023-04-04 20:35:02
【问题描述】:

当我在使用 npx create-react-app 创建应用程序后尝试运行 npm start 时,它会执行任何操作并以代码 0 退出。

当我尝试执行 npm start 命令时,我收到以下消息:

C:\projects\novo-curriculo\ui>npm start

> novo-curriculo-ui@0.1.0 start C:\projects\novo-curriculo\ui
> react-scripts start

当我启用 --verbose 选项时,我会收到以下日志,这些日志也是无用的。

C:\projects\novo-curriculo\ui>npm start --verbose
npm info it worked if it ends with ok
npm verb cli [
npm verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\gabriel\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'start',
npm verb cli   '--verbose'
npm verb cli ]
npm info using npm@6.14.5
npm info using node@v12.16.3
npm verb run-script [ 'prestart', 'start', 'poststart' ]
npm info lifecycle novo-curriculo-ui@0.1.0~prestart: novo-curriculo-ui@0.1.0
npm info lifecycle novo-curriculo-ui@0.1.0~start: novo-curriculo-ui@0.1.0

> novo-curriculo-ui@0.1.0 start C:\projects\novo-curriculo\ui
> react-scripts start

npm verb lifecycle novo-curriculo-ui@0.1.0~start: unsafe-perm in lifecycle true
npm verb lifecycle novo-curriculo-ui@0.1.0~start: PATH: C:\Users\gabriel\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\projects\novo-curriculo\ui\node_modules\.bin;C:\Python38\Scripts\;C:\Python38\;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Program Files\nodejs\;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\gabriel\AppData\Local\Microsoft\WindowsApps;C:\Users\gabriel\AppData\Local\Programs\Microsoft VS Code\bin;C:\xampp\php\;C:\Users\gabriel\AppData\Local\ComposerSetup\bin;C:\Users\gabriel\AppData\Roaming\Composer\vendor\bin;C:\Program Files\MySQL\MySQL Workbench 8.0 CE\;C:\sqlite\;C:\Users\gabriel\AppData\Local\Android\Sdk\platform-tools;C:\Users\gabriel\AppData\Local\Android\Sdk\emulator;C:\Users\gabriel\Anaconda3;C:\Users\gabriel\Anaconda3\Scripts;c:\flutter\bin;C:\Users\gabriel\AppData\Roaming\npm
npm verb lifecycle novo-curriculo-ui@0.1.0~start: CWD: C:\projects\novo-curriculo\ui
npm info lifecycle novo-curriculo-ui@0.1.0~poststart: novo-curriculo-ui@0.1.0
npm verb exit [ 0, true ]
npm timing npm Completed in 701ms
npm info ok

在这里你可以看到我的 package.json:

{
  "name": "novo-curriculo-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

npm 配置:

C:\projects\novo-curriculo\ui>npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.5 node/v12.16.3 win32 x64"

; userconfig C:\Users\gabriel\.npmrc
ignore-scripts = false

; builtin config undefined
prefix = "C:\\Users\\gabriel\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\projects\novo-curriculo\ui
; HOME = C:\Users\gabriel
; "npm config ls -l" to show all defaults.

还有 npm 全局配置。

C:\projects\novo-curriculo\ui>npm config -g list
; cli configs
global = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.5 node/v12.16.3 win32 x64"

; userconfig C:\Users\gabriel\.npmrc
ignore-scripts = false

; builtin config undefined
prefix = "C:\\Users\\gabriel\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\projects\novo-curriculo\ui
; HOME = C:\Users\gabriel
; "npm config ls -l" to show all defaults.

我整天都在尝试解决这个问题,但没有成功。其他人也有这个吗?

我的系统信息如下,我尝试在命令提示符 (cmd) 和 Power Shell 上运行它 - 两者结果相同。

  • Windows 10 专业版(10.0.18363 Build 18363)
  • NPM 6.14.5
  • v12.16.3

谢谢。

【问题讨论】:

  • 你的 IDE 是什么?
  • 听起来像是github.com/facebook/create-react-app/issues 的问题,你先在那里快速搜索了吗?
  • 请原谅我的无知,但你在期待什么?当我运行npm start 时,也会发生同样的事情。然后我去浏览我的 web api 和 web 浏览器,一切都按预期运行
  • 我假设您是 .NET 开发人员。如果是这种情况,NPM 不会实时运行 Visual Studio 和 IIS,您必须手动打开浏览器。然后,浏览 localhost:8000。
  • 你可以把它放在WeTransfer。我只是想,你说在其他项目中它对你有用,所以我想知道那个项目是否有什么奇怪的地方......

标签: node.js reactjs npm


【解决方案1】:

我已经帮助@Gabriel 调试了这个问题,我不得不说,这是一个非常奇怪的问题。

首先,立即解决方法:重命名文件夹novo-curriculo 修复它。(请注意,这不是项目文件夹本身,而是my-ui,而是它上面的一个。)

真正的答案是:“Warsaw”应用正在干扰您的应用。

这是 GAS Tecnologica/Diebold/Nixdorf 的一款软件,一些巴西银行使用“保护模块”以某种方式保护其在线银行访问免受计算机上的恶意软件的侵害。卸载它可以解决问题(可能还有计算机上的其他一些问题)。只需转到“添加/删除程序”并查找“华沙”并将其删除。

(顺便说一句,这不是这个保护模块第一次引起问题。In 2015 it caused IPv6 connections to break.


据我所知,技术解释如下:

首先我们必须知道npm start 会导致这里产生一系列子进程。

  • node "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" start
  • node "C:\projects\novo-curriculo\my-ui\node_modules\.bin\react-scripts" start
  • node "C:\projects\novo-curriculo\my-ui\node_modules\.bin\..\react-scripts\bin\react-scripts.js" start

最后一个启动失败。它以一种非常奇怪的方式这样做:该进程已创建但立即退出,“成功” - 退出代码为零。因此,没有显示任何错误,除了进程立即退出之外,没有任何异常。

可以在进程监视器中看到:

这里显示的是,在进程启动后(它刚刚加载了ntdll.dll,甚至还没有加载任何其他 DLL 依赖项)它退出了。这是非常不寻常的。

但它变得更加神秘,因为手动测试表明node node_modules\react-scripts\bin\react-scripts.js start 可以正常工作,而node "C:\projects\novo-curriculo\my-ui\node_modules\react-scripts\bin\react-scripts.js start" 则不行。

使用命令行表明它与所涉及的实际物理文件夹或文件无关。 node --version 通常打印 node.js 版本,即使后面跟着另一个参数,比如 node --version abcdefg。但是,只要我提出一个包含模式\*novo-curriculo*\*.js(并且可执行文件是node)的参数,它就会退出而不打印版本!例如,node --version \1111novo-curriculo1111\1111.js

尝试在x64dbg中调试node进程,很明显是一些未知的外力一启动就关闭了进程,因为即使x64dbg在ntdll被加载的时候闯入了进程,它也已经消失了当反汇编被加载时,尝试执行一条指令立即导致“调试停止”,处理已经终止,退出代码为零。

因此,它一定是某种机制,可能是内核驱动程序或服务,如果它们的命令行与某些模式匹配,它会在进程启动时立即终止进程。这听起来像是一个恶意软件(虽然 rootkit 扫描恢复了干净),或者是防病毒软件(情况并非如此,因为唯一的防病毒软件是 Windows Defender),或者某种(编程错误) 一些游戏的反作弊系统。原来最后一个几乎是对的——就是网上银行保护系统!

所以,底线:这个华沙网上银行“保护模块”(应该可以在您使用网上银行时保护您免受间谍软件的侵害)编程错误并且可以在没有任何明显原因的情况下终止其他进程(当它们的命令行匹配时某种模式)并且没有给出任何警告或信息。

【讨论】:

    【解决方案2】:
    1. 确保您使用的是最新的 npm 版本
    2. 删除node_modules文件夹并运行npm install
    3. 确保在启动 react 应用时有足够的内存
    4. 尝试以管理员身份运行cmd

    【讨论】:

    • 永远,永远,做 (4)。 npm 专门设计为永远不需要管理员权限,因为来自 npm 的代码是不受信任的,并且由于postinstall 脚本,你可以在没有你说你同意的情况下彻底擦除你的整个填充系统。再说一遍:永远,永远,以管理员身份运行 npm
    【解决方案3】:

    让我们回到基础:create-react-app 通常是全局安装的,因为它是一个项目构建器,而不是“库”,所以我使用以下步骤可以正常工作:

    D:\temp>npm install -g create-react-app
    
    [...create-react-app install log]
    
    D:\temp>create-react-app test
    
    Creating a new React app in D:\temp\test.
    
    Installing packages. This might take a couple of minutes.
    Installing react, react-dom, and react-scripts with cra-template...
    
    [...bootstrapping log...]
    
    We suggest that you begin by typing:
    
      cd test
      npm start
    
    Happy hacking!
    

    所以这是直截了当的:它告诉我们该怎么做:

    D:\temp>cd test
    
    D:\temp\test>npm start
    
    > test@0.1.0 start D:\temp\test
    > react-scripts start
    
    [ screen wipe ]
    
    Compiled successfully!
    
    You can now view test in the browser.
    
      http://localhost:3000
    
    Note that the development build is not optimized.
    To create a production build, use npm run build.
    

    所以这很好用:您执行了哪些步骤与这些步骤不同

    【讨论】:

    • 没用。我和你做的完全一样,并且在开始之前得到了相同的输出。但是当我执行 npm start 时,它显示 ``` C:\projects\novo-curriculo\my-ui>npm start > my-ui@0.1.0 start C:\projects\novo-curriculo\my-ui > react-scripts 开始 C:\projects\novo-curriculo\my-ui> ```
    • 如果您确实运行了这些完全相同的命令并且它不起作用,那么这对 SO 来说不是一个问题:您真的应该在 github.com/facebook/create-react-app/issues 上将此作为问题提交,因为您遇到了开发人员应注意并帮助修复的错误。
    • @Mike'Pomax'Kamermans 原来是a totally different issue,一个由网上银行保护应用程序引起的偷偷摸摸的,与create-react-app无关
    猜你喜欢
    • 1970-01-01
    • 2014-11-17
    • 2019-03-21
    • 2018-05-04
    • 2020-04-23
    • 2022-01-09
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多