I am trying to convert MS Word files (.docx/.doc) to *.pdf file but didn't find any .net core package to do so.
Then I thought to use Node.js package for the same and to run it inside my .Net Core app. I tried node-msoffice-pdf node package. I first created a sample Node app just to test if this package works but when I run it, I get following error:
D:\Projects\test\node_modules\edge\lib\edge.js:169
return edge.initializeClrFunc(options);
^
Error: Unable to compile C# code.
----> Errors when compiling as a CLR library:
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.d
ll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.PowerPoint\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Po
werPoint.dll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Office\15.0.0.0__71e9bce111e9429c\Office.dll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Vbe.Interop\15.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.dll' could not be f
ound
----> Errors when compiling as a CLR async lambda expression:
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.d
ll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.PowerPoint\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Po
werPoint.dll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Office\15.0.0.0__71e9bce111e9429c\Office.dll' could not be found
error CS0006: Metadata file 'C:\Windows\assembly\GAC_MSIL\Microsoft.Vbe.Interop\15.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.dll' could not be f
ound
at Error (native)
at Object.exports.func (D:\Projects\test\node_modules\edge\lib\edge.js:169:17)
at Object.<anonymous> (D:\Projects\test\node_modules\node-msoffice-pdf\lib.js:4:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Projects\test\server\api\todo\controller\todo-controller.js:3:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Projects\test\server\api\todo\route\todo-route.js:3:25)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
What's the best way to convert MS Word files to PDF in .Net Core?
This Node.js package doesn't work for the same reason that the .NET Core one doesn't: it's calling Microsoft.Office.Interop, and that only works on Windows machines with the Office interop stuff installed.
Basically, when .NET Core compiles it knows that Microsoft.Office.Interop might not be available when it's installed, so throws an error then. However JS isn't compiled and finds out at run-time that it's installed on a server/container where C:\Windows\assembly\GAC_MSIL\... just isn't there.
Wrapping a Node.js app in your .NET Core just moves this problem from compile-time to run-time.
Related
I have bot in Discord Bot Maker. Its working perfectly on my pc (Windows 10), but when I move it to my VPS (Ubuntu 16.04) and try to start it using node bot.js, I will get error with missing module.
Error:
module.js:550
throw err;
^
Error: Cannot find module './constants'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/justwolf/butter/node_modules/ws/lib/websocket.js:19:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
bot.js: https://hastebin.com/koredupoka.js
The error :
Error: Cannot find module './constants'
means that somewhere in your code you have
.... = require('./constants')
but the file constants.js doesn't exist or at least not where it's supposed to be. Maybe when you uploaded your bot script to your VPS you forgot to upload that file.
Sometimes, in ready-made scripts, configuration variables such as database credentials and stuff are stored in a file named constants.js and this file is not versionned (it has en entry in .gitignore). Maybe you have a file named constants.js.dist or constants.js.example. It means you need to edit it and rename it to constants.js
After installing express-gateway, when I create API gateway using following command,
eg gateway create
I am getting following error.
[EG:config] error: Cannot find module 'C:\My Content\Microservice Projects\FIFA Team Selection\config\models\users.json'
C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\index.js:15
throw err;
^
Error: Cannot find module 'C:\My Content\Microservice Projects\FIFA Team Selection\config\models\users.json'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at forEach.model (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\config.js:68:27)
at Array.forEach (<anonymous>)
at Config.loadModels (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\config.js:65:61)
at Object.<anonymous> (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\index.js:11:10)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
child_process.js:624
throw err;
^
Error: Command failed: C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\.bin\eg.cmd gateway create
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at exports.executeInScope.env (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\execution-scope.js:37:5)
at Object.exports.bootstrap (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\environment.js:11:7)
at Object.<anonymous> (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\index.js:9:46)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
I tried removing node_modules folder and re-installing it again, but issue persists.
This can usually happen when something is wrong during the scaffolding/creation section. I can also see you're running the command from Windows.
We had different users complaining about some weird CLI problems with that operating system which I'm not actively supporting right now.
It shouldn't be too hard to copy that file from the repository and place it in the right directory. I know it's a workaround, but it should do the trick.
I'm tired of this error! This is Serverless app with Lambda in AWS. Locally it works perfectly. Testing locally didn't work for load of other reasons. I'm testing in staging. Yet I'm getting this error:
Unable to import module 'src/engine/handler': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous>(/var/task/src/engine/controllers/image.js:43:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I followed all the steps advised elsewhere including: moving all dependencies to dependencies (out of dev), installing serverless and all. I'm using Node 6.10.3 and TypeScript 3.1. Can you help?
If you're trying host your nodejs projects which has so many dependencies not related to aws services inside, you better zip your projects in S3 first then import lambda from S3.
I have nodejs azure function that using sqlite3 lib. after running the function. i got this error.
2017-10-12T10:49:16.036 Function started
2017-10-12T10:49:19.434 Exception while executing function: Functions.sqlite.
mscorlib: One or more errors occurred. Error: A dynamic link library (DLL)
initialization routine failed.
\\?\D:\home\site\wwwroot\sqlite\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\home\site\wwwroot\sqlite\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10).
2017-10-12T10:49:19.449 Function completed (Failure, Duration=3415ms)
any idea how to solve this error?
I solve the problem using Sql.js lib
https://github.com/kripken/sql.js/
I have been following the instructions to install Mocha with WebStorm found here: https://www.jetbrains.com/help/webstorm/2017.1/testing-javascript-with-mocha.html#d194239e92
I have set the configurations to run files that match the pattern: **/*.spec.js
node interpreter: /usr/bin/node
working directory:/home/web/app
mocha package:/home/web/app/node_modules/mocha
I am writing in TypeScript which is converted to ES6, the output of which is what I'm attempting to test. However I get this error which I don't understand and so don't really know where to begin looking to resolve.
I don't understand why it is looking for "ts-node", considering it's only supposed to look for "spec.js" files. and past that, I don't understand why the folder it is looking for in ts-node is missing. I have uninstalled then re-installed ts-node a couple times, neither of which yielded the sought after folder... I have no clue as to how to proceed or even what further information is needed to help resolve this issue.
Any help would be appreciated. I just want to test my application and this is proving to be a real headache.
Here is the error:
/usr/bin/node /home/web/app/node_modules/mocha/bin/_mocha --ui bdd
--reporter /opt/webstorm/ws/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js
**/*.spec.js TypeError: The specified path does not exist: /home/web/app/node_modules/ts-node/tests
at resolveSync (/home/web/app/node_modules/ts-node/node_modules/tsconfig/src/tsconfig.ts:72:9)
at Object.loadSync (/home/web/app/node_modules/ts-node/node_modules/tsconfig/src/tsconfig.ts:140:16)
at readConfig (/home/web/app/node_modules/ts-node/src/index.ts:418:18)
at Object.register (/home/web/app/node_modules/ts-node/src/index.ts:176:18)
at Suite. (/home/web/app/node_modules/ts-node/src/index.spec.ts:190:5)
at Object.create (/home/web/app/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/home/web/app/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Suite. (/home/web/app/node_modules/ts-node/src/index.spec.ts:189:3)
at Object.create (/home/web/app/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/home/web/app/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object. (/home/web/app/node_modules/ts-node/src/index.spec.ts:13:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/web/app/node_modules/mocha/lib/mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (/home/web/app/node_modules/mocha/lib/mocha.js:227:14)
at Mocha.run (/home/web/app/node_modules/mocha/lib/mocha.js:495:10)
at Object. (/home/web/app/node_modules/mocha/bin/_mocha:460:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
Process finished with exit code 1
I figured it out, my path was from the root of my project, which contained node_modules, and so the node_modules directory was being tested, causing errors from tests inside the ts-node folder. the fix was to exclude node_modules directory from the specified path for test modules.