2

Running npm start, npm run or npm run-script fails with npm ERR! errno 3221225781

My node is cleanly installed stable version 10.16.3 LTS with npm 6.9.0 on Windows 10. Everything is installed on the default path on C:.

My example is a minimal setup with the current file structure:

node_modules/ <empty>
index.js
package.json

The node_modules folder is empty.

The index.js:

console.log("Hello world..");

The package.json:

{
  "name": "testnpm",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  }
}

Running npm start

H:\dev\javascript\testnpm>npm start

> testnpm@1.0.0 start H:\dev\javascript\testnpm
> node index.js

npm ERR! code ELIFECYCLE
npm ERR! errno 3221225781
npm ERR! testnpm@1.0.0 start: `node index.js`
npm ERR! Exit status 3221225781
npm ERR!
npm ERR! Failed at the testnpm@1.0.0 start 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! <Path to logs>\_logs\2019-10-19T13_24_15_158Z-debug.log

The expected output would be "Hello World.." but fails as shown above.

Running the same command directly gives the expected result:

H:\dev\javascript\testnpm>node index.js
Hello world..

Here's the log after failure:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle testnpm@1.0.0~prestart: testnpm@1.0.0
6 info lifecycle testnpm@1.0.0~start: testnpm@1.0.0
7 verbose lifecycle testnpm@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle testnpm@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;H:\dev\javascript\testnpm\node_modules\.bin;...
9 verbose lifecycle testnpm@1.0.0~start: CWD: H:\dev\javascript\testnpm
10 silly lifecycle testnpm@1.0.0~start: Args: [ '-c', 'node index.js' ]
11 silly lifecycle testnpm@1.0.0~start: Returned: code: 3221225781  signal: null
12 info lifecycle testnpm@1.0.0~start: Failed to exec start script
13 verbose stack Error: testnpm@1.0.0 start: `node index.js`
13 verbose stack Exit status 3221225781
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid testnpm@1.0.0
15 verbose cwd H:\dev\javascript\testnpm
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.3
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 3221225781
22 error testnpm@1.0.0 start: `node index.js`
22 error Exit status 3221225781
23 error Failed at the testnpm@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3221225781, true ]

To be clear, npm install and such works. Starting a script with node works fine too. The only thing not working is running any of the defined scripts in package.json with npm.

====================================

EDIT:

  1. Same error after updating npm with npm i -g npm
  2. Clue: Error code 3221225781 just happens to be the code for missing dll in .NET
  3. I've uninstalled all development libraries, IDE's, distributables, and reinstalled only necessary according to install description from npm on github. Still same error.
  4. It works in Git Bash! But still same error in CMD and PowerShell. It made me suspect PATH, added all the Git Bash paths in CMD manually to try, and it's still the same error.
  5. Did a FULL Reinstall of Windows, ran the node install which now installs chocolatey and that in turn installs the following dependencies:
 - chocolatey-dotnetfx.extension v1.0.1
 - python2 v2.7.17
 - kb3033929 v1.0.5
 - visualstudio2017buildtools v15.9.17.0
 - chocolatey-windowsupdate.extension v1.0.4
 - vcredist140 v14.23.27820
 - kb2999226 v1.0.20181019
 - visualstudio-installer v2.0.1
 - kb2919355 v1.0.20160915
 - chocolatey-core.extension v1.3.3
 - kb2919442 v1.0.20160915
 - visualstudio2017-workload-vctools v1.3.2
 - chocolatey-visualstudio.extension v1.8.1
 - dotnetfx v4.8.0.20190930
 - kb3035131 v1.0.3
  1. It now works, what the actual problem was will likely remain a mystery.
Karlsson
  • 203
  • 3
  • 13

2 Answers2

0

Orignal Answer

It looks like it is a problem with one of npm-cli's dependencies.

Run npm i -g npm and try again. It should mostly get rid of your problem.

Edit

I did some research. I primarily use node on linux, so wasn't aware of this. On Windows, you need VC++ redistributables installed.

You can Download from https://www.microsoft.com/en-us/download/details.aspx?id=48145

Source : https://github.com/electron/electron-quick-start/issues/55

Rohith Balaji
  • 848
  • 7
  • 21
  • It did update npm to 6.12.0 , other than that it's still the same error. I should also say that I've thoroughly wiped everything related to node, npm, their caches and paths and so on before trying this clean approach. Before that I tried with various versions of node/npm all with the exact same error. – Karlsson Oct 19 '19 at 14:25
  • The source has exactly the same verbose debug log as you. And installing VC++ fixed it for him. – Rohith Balaji Oct 19 '19 at 14:38
  • I already have VC++ redistributables installed, but tried anyway to make sure.. The installers (x86 and x64) does not let me install them again over my previous install. I also have zero dependencies, so I don't have the electron app problem. It's not impossible though that it can have something to do with microsoft redistributables of some other kind, as I have visual studio and lots of packages installed through that. Thanks for trying! – Karlsson Oct 19 '19 at 15:34
0

Try npm cache clean and I know the node_modules directory is empty but just delete it to be safe. You should also delete your package-lock.json file. Then run npm install.

Matt Croak
  • 2,788
  • 2
  • 17
  • 35
  • I've done all those things, also removed npm folders in AppData and so on, even restarted Windows twice in between clean installs. I cleaned with `--force`. `npm install` runs and creates a `package-lock.json`, but it's the same error no matter the file exists or not. – Karlsson Oct 19 '19 at 15:26
  • @Karlsson the exit status of 3221225781 could indicate an issue/missed step with VS Code installation. Have you tried re-installing the editor? – Matt Croak Oct 19 '19 at 16:16
  • Why would I need to install VSCode for npm to work? – Karlsson Oct 19 '19 at 16:39
  • @Karlsson Sorry I meant VC++ as I thought you were using as the environment. As said above the 3221225781 error could indicate an issue during environment installation/configuration and from what I’ve found online that code doesn’t appear to pertain to npm. Since you’ve cleaned cache, deleted package-lock etc. the issue doesn’t appear to be with Node or npm. The error response also said it’s probably not an issue with npm. It can’t hurt to uninstall and reinstall the editor. – Matt Croak Oct 19 '19 at 17:56
  • Fair enough, it's already fully uninstalled though. Thank you for helping, you're very kind. – Karlsson Oct 19 '19 at 18:10