AZn5ReD / saplearninghub-pdf-downloader

Download eBook from SAP Learning Hub
MIT License
46 stars 37 forks source link

Module Not Found Warnings #4

Closed sag8 closed 4 years ago

sag8 commented 4 years ago

I might be doing something wrong, but I get warnings for several modules not found when I run the command "npm run build" and I think as a result "npm run start" fails saying - "'env' is not recognized as an internal or external command,". (Complete error at the end.)

Warnings after "npm run build":

WARNING in ./node_modules/ws/lib/buffer-util.js
Module not found: Error: Can't resolve 'bufferutil' in 'D:\GitHub\saplearninghub-pdf-downloader\node_modules\ws\lib'
 @ ./node_modules/ws/lib/buffer-util.js
 @ ./node_modules/ws/lib/websocket.js
 @ ./node_modules/ws/index.js
 @ ./node_modules/puppeteer/lib/WebSocketTransport.js
 @ ./node_modules/puppeteer/lib/Launcher.js
 @ ./node_modules/puppeteer/lib/Puppeteer.js
 @ ./node_modules/puppeteer/index.js
 @ ./src/main.js
 @ ./src/index.js

WARNING in ./node_modules/fontkit/index.js
Module not found: Error: Can't resolve 'iconv-lite' in 'D:\GitHub\saplearninghub-pdf-downloader\node_modules\fontkit'
 @ ./node_modules/fontkit/index.js
 @ ./node_modules/pdfkit/js/pdfkit.js
 @ ./src/file.js
 @ ./src/main.js
 @ ./src/index.js

WARNING in ./node_modules/restructure/src/EncodeStream.js
Module not found: Error: Can't resolve 'iconv-lite' in 'D:\GitHub\saplearninghub-pdf-downloader\node_modules\restructure\src'
 @ ./node_modules/restructure/src/EncodeStream.js
 @ ./node_modules/restructure/index.js
 @ ./node_modules/fontkit/index.js
 @ ./node_modules/pdfkit/js/pdfkit.js
 @ ./src/file.js
 @ ./src/main.js
 @ ./src/index.js

WARNING in ./node_modules/restructure/src/DecodeStream.js
Module not found: Error: Can't resolve 'iconv-lite' in 'D:\GitHub\saplearninghub-pdf-downloader\node_modules\restructure\src'
 @ ./node_modules/restructure/src/DecodeStream.js
 @ ./node_modules/restructure/index.js
 @ ./node_modules/fontkit/index.js
 @ ./node_modules/pdfkit/js/pdfkit.js
 @ ./src/file.js
 @ ./src/main.js
 @ ./src/index.js

WARNING in ./node_modules/ws/lib/validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in 'D:\GitHub\saplearninghub-pdf-downloader\node_modules\ws\lib'
 @ ./node_modules/ws/lib/validation.js
 @ ./node_modules/ws/lib/sender.js
 @ ./node_modules/ws/index.js
 @ ./node_modules/puppeteer/lib/WebSocketTransport.js
 @ ./node_modules/puppeteer/lib/Launcher.js
 @ ./node_modules/puppeteer/lib/Puppeteer.js
 @ ./node_modules/puppeteer/index.js
 @ ./src/main.js
 @ ./src/index.js

Error after "npm run start":

> env NODE_ENV=production node ./dist/index.js

'env' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saplearninghub-pdf-downloader@1.0.0 start: `env NODE_ENV=production node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the saplearninghub-pdf-downloader@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:
AZn5ReD commented 4 years ago

Have you tried running : "npm install" first ?

sag8 commented 4 years ago

Have you tried running : "npm install" first ?

That was one quick reply. Thanks for the proactiveness and for building this tool.

Now, to answer the question - yes I did run npm install before running build command. After some googling, I found a way to save the missing packages displayed in the warning. Used the commands below:

But start is still giving me the same error.

(Also, I'm using Windows 10, if that makes any difference.)

AZn5ReD commented 4 years ago

Could you please pull the last version, I made some changes in the commands.

sag8 commented 4 years ago

Sure, I'll pull the latest version.

Before I do that, I'll like to let you know about the different ways I tried to fix this -

In both cases, I now get this error:

D:\GitHub\saplearninghub-pdf-downloader>npm run start

> saplearninghub-pdf-downloader@1.0.0 start D:\GitHub\saplearninghub-pdf-downloader
> set NODE_ENV=production && node ./dist/index.js

Error while reading config file: SyntaxError: Unexpected token C in JSON at position 220
    at JSON.parse (<anonymous>)
    at Module.<anonymous> (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:18:846278)
    at t (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:110)
    at D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:902
    at Object.<anonymous> (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:913)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
Starting script...
(node:16624) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error during puppeteer initialisation: Error: Could not find browser revision 737027. Run "npm install" or "yarn install" to download a browser binary.
    at w.launch (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:1176908)
TypeError: Cannot read property 'browser' of undefined
    at D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:18:854725
    at s (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:1024883)
    at Generator._invoke (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:1024636)
    at Generator.forEach.e.<computed> [as next] (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:1025240)
    at t (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:12899)
    at c (D:\GitHub\saplearninghub-pdf-downloader\dist\index.js:1:13110)

I tried find a solution to this program but have failed to find a proper answer. I can see .local-chromium folder in Puppeteer's directory. I tried running Chrome.exe from there and it's working properly.

Will pull the latest version and report back.

sag8 commented 4 years ago

Deleted the whole folder and pulled the whole project again. Now, I'm getting the Chromium error I mentioned above. "ENV is not a valid command" is resolved now. Thanks.

AZn5ReD commented 4 years ago

Could you please share de "config.json" file ? (Be sure to remove sensitive information first)

sag8 commented 4 years ago

Here you go -

{
  "DOWNLOAD_URL": "https://saplearninghub.plateau.com/icontent_e/CUSTOM_eu/sap/self-managed/ebook/BC401_EN_Col16_R1.3/index.html",
  "LOGIN": "sagarsheokand@xxxx.com",
  "PASSWORD": "abc123",
  "TARGET_DIR": "D:\Clouds\Mega\LearningHub Downloads",
  "DEBUG": false,
  "CHROME_EXE": "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
  "CHILD_STREAM": false
}
AZn5ReD commented 4 years ago

Ok, I haven't tried on Windows. You need to double the backslash on each path : \\

{
  "DOWNLOAD_URL": "https://saplearninghub.plateau.com/icontent_e/CUSTOM_eu/sap/self-managed/ebook/BC401_EN_Col16_R1.3/index.html",
  "LOGIN": "sagarsheokand@xxxx.com",
  "PASSWORD": "abc123",
  "TARGET_DIR": "D:\\Clouds\\Mega\\LearningHub Downloads",
  "DEBUG": false,
  "CHROME_EXE": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
  "CHILD_STREAM": false
}
sag8 commented 4 years ago

Ok, I haven't tried on Windows. You need to double the backslash on each path : \

{
  "DOWNLOAD_URL": "https://saplearninghub.plateau.com/icontent_e/CUSTOM_eu/sap/self-managed/ebook/BC401_EN_Col16_R1.3/index.html",
  "LOGIN": "sagarsheokand@xxxx.com",
  "PASSWORD": "abc123",
  "TARGET_DIR": "D:\\Clouds\\Mega\\LearningHub Downloads",
  "DEBUG": false,
  "CHROME_EXE": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
  "CHILD_STREAM": false
}

And it worked! Downloaded one book successfully. I'll try downloading some more books. Thanks, mate.