简体   繁体   English

npm 启动对 windows 没有任何作用

[英]npm start does nothing on windows

When I try to run npm start just after creating application with npx create-react-app, it does anything and exits with code 0.当我尝试在使用 npx create-react-app 创建应用程序后立即运行 npm start 时,它会执行任何操作并以代码 0 退出。

When I try to execute npm start command, I get the following message:当我尝试执行 npm 启动命令时,我收到以下消息:

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

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

When I enable --verbose options, I receive the following logs, which are useless too.当我启用 --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

Here you can see my package.json:在这里你可以看到我的 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"
    ]
  }
}

The npm configuration: 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.

And the npm global configuration.以及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.

I've spend all the day trying to solve this issue, but without success.我整天都在试图解决这个问题,但没有成功。 Does anybody else having this also?其他人也有这个吗?

My system information is the following and I've tried to run this on command prompt (cmd) and Power Shell - both with the same results.我的系统信息如下,我尝试在命令提示符 (cmd) 和 Power Shell 上运行它——结果相同。

  • Windows 10 Pro (10.0.18363 Build 18363) Windows 10 Pro(10.0.18363 Build 18363)
  • NPM 6.14.5 NPM 6.14.5
  • v12.16.3 v12.16.3

Thank you.谢谢你。

I've helped @Gabriel to debug the issue, and I have to say, it's a really weird one.我已经帮助@Gabriel 调试了这个问题,我不得不说,这真的很奇怪。

First, the immediate workaround: Renaming the folder novo-curriculo fixes it.首先,直接的解决方法:重命名文件夹novo-curriculo修复它。 (Note that this is not the project folder itself, that would be my-ui , but one above it.) (请注意,这不是项目文件夹本身,而是my-ui ,而是它上面的一个。)

The real answer is: The application "Warsaw" is interfering with your app.真正的答案是:应用程序“Warsaw”正在干扰您的应用程序。

It's a piece of software by GAS Tecnologica/Diebold/Nixdorf, a "protection module" used by some Brazilian banks to somehow protect their online banking access from malware on the computer.它是 GAS Tecnologica/Diebold/Nixdorf 的一款软件,这是一些巴西银行使用的“保护模块”,以某种方式保护其在线银行访问免受计算机上的恶意软件的侵害。 Uninstalling it fixes the issue (and possibly some other issues on the computer as well).卸载它可以解决问题(可能还有计算机上的其他一些问题)。 Just go to "Add/Remove Programs" and look for "Warsaw" and remove it.只需 go 到“添加/删除程序”并查找“华沙”并将其删除。

(This is not the first time that this protection module caused issues, by the way. In 2015 it caused IPv6 connections to break. ) (顺便说一句,这不是这个保护模块第一次引起问题。2015 年它导致 IPv6 连接中断。


The technical explanation, as far as I was able to figure it out, is as follows:据我所知,技术解释如下:

First we have to know that npm start causes a chain of subprocesses to be spawned here.首先我们要知道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

The last one failed to start.最后一个启动失败。 And it did so in a really weird way: The process was created but immediately exited, with "success" - exit code zero.它以一种非常奇怪的方式这样做:该过程已创建但立即退出,“成功” - 退出代码为零。 So, no error was shown, nothing out of the ordinary other than just the process immediately exiting.因此,没有显示任何错误,除了进程立即退出之外没有任何异常。

It can be seen here in Process Monitor:可以在 Process Monitor 中看到:

ProcMon 屏幕截图

What's shown here is that immediately after the process starts (it just loaded ntdll.dll and didn't even load any of the other DLL dependencies yet) it quits.这里显示的是,在进程启动后(它只是加载ntdll.dll ,甚至还没有加载任何其他 DLL 依赖项),它就退出了。 This is highly unusual.这是非常不寻常的。

But it gets even more mysterious, because manual testing revealed that node node_modules\react-scripts\bin\react-scripts.js start would work fine, while node "C:\projects\novo-curriculo\my-ui\node_modules\react-scripts\bin\react-scripts.js start" would not.但它变得更加神秘,因为手动测试显示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"不会。

Playing around with the command line showed that it has nothing to do with the actual physical folders or files involved.玩弄命令行表明它与所涉及的实际物理文件夹或文件无关。 node --version normally prints the node.js version, even if followed by another argument, say node --version abcdefg . node --version通常打印 node.js 版本,即使后面跟着另一个参数,比如node --version abcdefg However, as soon as I put an argument that contained the pattern \*novo-curriculo*\*.js (and the executable was node ), it exited without printing the version, For example, node --version \1111novo-curriculo1111\1111.js .但是,只要我输入一个包含模式\*novo-curriculo*\*.js的参数(并且可执行文件是node ),它就会退出而不打印版本,例如node --version \1111novo-curriculo1111\1111.js

Trying to debug the node process in x64dbg made it obvious that some unknown external force closed the process as soon as it was started, because even if x64dbg broke into the process at the point ntdll was loaded, it was already gone by the time the disassembly was loaded, and trying to execute a single instruction immediately resulted in "debugging stopped", with the processing having died with exit code zero.尝试在x64dbg中调试node进程,很明显是一些未知的外力一启动就关闭了该进程,因为即使x64dbg在ntdll加载的时候闯入了进程,到反汇编的时候它已经消失了已加载,并尝试立即执行单个指令导致“调试停止”,处理已终止,退出代码为零。

Therefore it must have been some sort of mechanism, probably a kernel driver or a service, that terminates processes as soon as they start if their command line matches certain patterns.因此,它一定是某种机制,可能是 kernel 驱动程序或服务,如果它们的命令行与某些模式匹配,它们会在进程启动时立即终止。 That would sound like either a piece of malware (a rootkit scan came back clean though), or anti-virus (which wasn't the case since the only anti-virus in play was Windows Defender), or some sort of (badly programmed) anti-cheat system of some game.这听起来像是一个恶意软件(尽管 rootkit 扫描恢复了干净),或者是防病毒软件(情况并非如此,因为唯一的防病毒软件是 Windows Defender),或者某种(编程错误) 一些游戏的反作弊系统。 Turned out the last one was almost right - it was the online banking protection system!原来最后一个几乎是对的——它是网上银行保护系统!

So, bottom line: This Warsaw "protection module" for online banking (which should supposedly protect you from spyware while you are using online banking) is badly programmed and can terminate other processes without any obvious reason (when their command line matches some sort of pattern) and without giving any warning or message about it.所以,底线:这个华沙的网上银行“保护模块”(它应该在你使用网上银行时保护你免受间谍软件的侵害)的程序很糟糕,并且可以在没有任何明显原因的情况下终止其他进程(当它们的命令行匹配某种模式)并且没有给出任何警告或信息。

  1. Make sure you are using the latest npm version确保您使用的是最新的 npm 版本
  2. Delete the node_modules folder and run npm install删除 node_modules 文件夹并运行npm install
  3. Make sure you have enough memory when starting the react app启动 react 应用程序时,请确保您有足够的 memory
  4. Try to run cmd as Administrator尝试以管理员身份运行 cmd

Let's get back to basics: create-react-app is generally installed globally because it's a project builder, not "a library", so I've got this working just fine using the following steps:让我们回到基础: 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!

So that's straight forward: it's telling us what to do:所以这是直截了当的:它告诉我们该怎么做:

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.

So this works just fine: what steps did you perform that differ form these?所以这很好用:你执行了哪些与这些不同的步骤?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM