bnoordhuis / node-iconv

node.js iconv bindings - text recoding for fun and profit!
Other
797 stars 123 forks source link

Can't compile using typescript #195

Closed domnich closed 5 years ago

domnich commented 5 years ago

Hello! I'm trying to create bundle js file from my ts file through webpack and Im receiving next error:

ModuleNotFoundError: Module not found: Error: Can't resolve '../build/Debug/iconv.node' in '/Users/idomnich/test/node_modules/iconv/lib'

node - v8.12.0 npm - v6.4.1

What I want is just to build my index.ts file, which contains 2 strings:

import { BrowserWindow, shell } from 'electron'; const jabra = require('jabra'); // iconv uses as sub module here, If you will try to remove const jabra = require('jabra') -> you will be able to create bundle file

I attached code sample and steps to reproduce this error are: 1) download example 2) npm install 3) npm run build:test

Archive.zip

Also tried to run node-gyp rebuild, node-gyp clean, npm install...and nothing of this didn't solve my problem

Any info will be very useful for me, thanks and Happy New Year!

Whole error text:

Using tsconfig.json from /Users/idomnich/test/src/tsconfig.json
ModuleNotFoundError: Module not found: Error: Can't resolve '../build/Debug/iconv.node' in '/Users/idomnich/test/node_modules/iconv/lib'
    at factory.create (/Users/idomnich/test/node_modules/webpack/lib/Compilation.js:821:10)
    at factory (/Users/idomnich/test/node_modules/webpack/lib/NormalModuleFactory.js:397:22)
    at resolver (/Users/idomnich/test/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/Users/idomnich/test/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /Users/idomnich/test/node_modules/neo-async/async.js:2825:7
    at /Users/idomnich/test/node_modules/neo-async/async.js:6886:13
    at normalResolver.resolve (/Users/idomnich/test/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
    at doResolve (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:184:12)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at resolver.doResolve (/Users/idomnich/test/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)
    at resolver.doResolve (/Users/idomnich/test/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:38)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn4 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:51:1)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)
    at resolver.doResolve (/Users/idomnich/test/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:38)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn1 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:24:1)
    at hook.callAsync (/Users/idomnich/test/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/Users/idomnich/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at fs.stat (/Users/idomnich/test/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:22:13)
    at process.nextTick (/Users/idomnich/test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:73:15)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
resolve '../build/Debug/iconv.node' in '/Users/idomnich/test/node_modules/iconv/lib'
  using description file: /Users/idomnich/test/node_modules/iconv/package.json (relative path: ./lib)
    using description file: /Users/idomnich/test/node_modules/iconv/package.json (relative path: ./build/Debug/iconv.node)
      no extension
        /Users/idomnich/test/node_modules/iconv/build/Debug/iconv.node doesn't exist
      .ts
        /Users/idomnich/test/node_modules/iconv/build/Debug/iconv.node.ts doesn't exist
      .js
        /Users/idomnich/test/node_modules/iconv/build/Debug/iconv.node.js doesn't exist
      as directory
        /Users/idomnich/test/node_modules/iconv/build/Debug/iconv.node doesn't exist
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 build:test: `webpack --config webpack/webpack.config.js --bail`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test@1.0.0 build:test 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!     /Users/idomnich/.npm/_logs/2018-12-31T11_48_06_637Z-debug.log
bnoordhuis commented 5 years ago

What does ls -lR /Users/idomnich/test/node_modules/iconv print? The error message suggests node-iconv hasn't been compiled.

domnich commented 5 years ago

It prints:

LICENSE binding.gyp lib src README.md build node_modules support bin deps package.json test

And in build folder, there is only Release folder and no Debug folder...

Makefile binding.Makefile gyp-mac-tool Release config.gypi iconv.target.mk

bnoordhuis commented 5 years ago

There should be an iconv.node in build/Release, or build/Debug as a fallback. If there isn't, you (somehow) didn't build it. Try running node-gyp --directory node_modules/iconv rebuild from your project's top-level directory.