How to Solve Error: Module did not self-register

1. Error description

[scss/sass] 14:56:38.373 internal/modules/cjs/loader.js:717
[scss/sass] 14:56:38.373   return process.dlopen(module, path.toNamespacedPath(filename));
[scss/sass] 14:56:38.373                  ^
[scss/sass] 14:56:38.373 Error: Module did not self-register.
[scss/sass] 14:56:38.373     at Object.Module._extensions..node (internal/modules/cjs/loader.js:717:18)
[scss/sass] 14:56:38.373     at Module.load (internal/modules/cjs/loader.js:598:32)
[scss/sass] 14:56:38.373     at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
[scss/sass] 14:56:38.373     at Function.Module._load (internal/modules/cjs/loader.js:529:3)
[scss/sass] 14:56:38.373     at Module.require (internal/modules/cjs/loader.js:636:17)
[scss/sass] 14:56:38.373     at require (internal/modules/cjs/helpers.js:20:18)
[scss/sass] 14:56:38.373     at module.exports (G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china\lib\binding.js:19:10)
[scss/sass] 14:56:38.373     at Object.<anonymous> (G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china\lib\index.js:14:35)
[scss/sass] 14:56:38.373     at Module._compile (internal/modules/cjs/loader.js:688:30)
[scss/sass] 14:56:38.373     at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)

2. Error reason
The error message is that the module is not registered and installed with NPM Install, but the result is still an error, indicating that the module has not been successfully installed

G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china\vendor\win32
-x64-64>npm install

> [email protected] install G:\HBuilderX\plugins\compile-node-sass\node_modu
les\node-sass-china
> node scripts/install.js

node-sass build Binary found at G:\HBuilderX\plugins\compile-node-sass\node_modu
les\node-sass-china\vendor\win32-x64-64\binding.node

> [email protected] postinstall G:\HBuilderX\plugins\compile-node-sass\node_
modules\node-sass-china
> node scripts/build.js

Binary found at G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-ch
ina\vendor\win32-x64-64\binding.node
Testing binary
Binary has a problem: Error: \\?\G:\HBuilderX\plugins\compile-node-sass\node_mod
ules\node-sass-china\vendor\win32-x64-64\binding.node is not a valid Win32 appli
cation.
\\?\G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china\vendor\w
in32-x64-64\binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:717:18)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at module.exports (G:\HBuilderX\plugins\compile-node-sass\node_modules\node-
sass-china\lib\binding.js:19:10)
    at Object.<anonymous> (G:\HBuilderX\plugins\compile-node-sass\node_modules\n
ode-sass-china\lib\index.js:14:35)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
Building the binary locally
Building: F:\nodejs\node.exe G:\HBuilderX\plugins\compile-node-sass\node_modules
\node-sass-china\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsa
ss_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'F:\\nodejs\\node.exe',
gyp verb cli   'G:\\HBuilderX\\plugins\\compile-node-sass\\node_modules\\node-sa
ss-china\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (G:\HBuilderX\plugins\compile-no
de-sass\node_modules\node-sass-china\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (G:\HBuilderX\plugins\compile-node-sass\node_mo
dules\node-sass-china\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (G:\HBuilderX\plugins\compile-node-sass\node_mo
dules\node-sass-china\node_modules\which\which.js:80:29)
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\which\which.js:89:16
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (G:\HBuilderX\plugins\compile-no
de-sass\node_modules\node-sass-china\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (G:\HBuilderX\plugins\compile-node-sass\node_mo
dules\node-sass-china\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (G:\HBuilderX\plugins\compile-node-sass\node_mo
dules\node-sass-china\node_modules\which\which.js:80:29)
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\which\which.js:89:16
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at G:\HBuilderX\plugins\compile-node-sass\node_modul
es\node-sass-china\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python2\n    at getNotFoundError (
G:\\HBuilderX\\plugins\\compile-node-sass\\node_modules\\node-sass-china\\node_m
odules\\which\\which.js:13:12)\n    at F (G:\\HBuilderX\\plugins\\compile-node-s
ass\\node_modules\\node-sass-china\\node_modules\\which\\which.js:68:19)\n    at
 E (G:\\HBuilderX\\plugins\\compile-node-sass\\node_modules\\node-sass-china\\no
de_modules\\which\\which.js:80:29)\n    at G:\\HBuilderX\\plugins\\compile-node-
sass\\node_modules\\node-sass-china\\node_modules\\which\\which.js:89:16\n    at
 G:\\HBuilderX\\plugins\\compile-node-sass\\node_modules\\node-sass-china\\node_
modules\\isexe\\index.js:42:5\n    at G:\\HBuilderX\\plugins\\compile-node-sass\
\node_modules\\node-sass-china\\node_modules\\isexe\\windows.js:36:5\n    at FSR
eqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python E:\Python\Python36\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: E:\Python\Python36\python.EXE -c import sy
s; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:381:11)

gyp ERR! stack     at Socket.emit (events.js:182:13)
gyp ERR! stack     at Pipe._handle.close (net.js:606:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "F:\\nodejs\\node.exe" "G:\\HBuilderX\\plugins\\compile-node-sa
ss\\node_modules\\node-sass-china\\node_modules\\node-gyp\\bin\\node-gyp.js" "re
build" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--
libsass_library="
gyp ERR! cwd G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china

gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     F:\nodejs\node_cache\_logs\2019-01-10T07_40_54_700Z-debug.log

G:\HBuilderX\plugins\compile-node-sass\node_modules\node-sass-china\vendor\win32
-x64-64>

3. Solutions
Uninstall and reinstall Sass related modules

C:\Users\Administrator.USER-0GUONPPBHK>npm uninstall node-sass -D
npm WARN Administrator.USER-0GUONPPBHK No repository field.
npm WARN Administrator.USER-0GUONPPBHK No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fse
vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]
1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)

added 33 packages from 16 contributors, removed 22 packages and updated 340 pack
ages in 26.067s

C:\Users\Administrator.USER-0GUONPPBHK>npm install node-sass -D

> [email protected] install C:\Users\Administrator.USER-0GUONPPBHK\node_modules\n
ode-sass
> node scripts/install.js

Cached binary found at F:\nodejs\node_cache\node-sass\4.11.0\win32-x64-64_bindin
g.node

> [email protected] postinstall C:\Users\Administrator.USER-0GUONPPBHK\node_modul
es\node-sass
> node scripts/build.js

Binary found at C:\Users\Administrator.USER-0GUONPPBHK\node_modules\node-sass\ve
ndor\win32-x64-64\binding.node
Testing binary
Binary is fine
npm WARN [email protected] requires a peer of [email protected]^2.5.2 but none is installed. Y
ou must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]^2.5.0 but none is installed.
 You must install peer dependencies yourself.
npm WARN Administrator.USER-0GUONPPBHK No repository field.
npm WARN Administrator.USER-0GUONPPBHK No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fse
vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]
1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)

+ [email protected]
added 110 packages from 118 contributors in 26.774s

C:\Users\Administrator.USER-0GUONPPBHK>

 


Read More: