I'm running a video processing script on AWS Lambda.
While it seems to work perfectly locally (tested using lambda-local), I'm having a strange issue when it runs on Lambda:
{
"errorMessage": "Cannot find module 'fluent-ffmpeg'",
"errorType": "Error",
"stackTrace": [
"Function.Module._resolveFilename (module.js:338:15)",
"Function.Module._load (module.js:280:25)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)",
"Object.<anonymous> (/var/task/processing.js:2:14)",
"Module._compile (module.js:456:26)",
"Object.Module._extensions..js (module.js:474:10)",
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)",
"Module.require (module.js:364:17)"
]
}
The ZIP I am uploading contains the following files:
~$ find . -maxdepth 2
.
./bin
./bin/ffmpeg
./config.js
./event-samples
./event-samples/custom.js
./event-samples/dynamodb-update.js
./event-samples/kinesis.js
./event-samples/s3-put.js
./frames
./Gulpfile.js
./index.js
./node_modules
./node_modules/async
./node_modules/aws-sdk
./node_modules/fluent-ffmpeg
./node_modules/gulp
./node_modules/gulp-awslambda
./node_modules/gulp-zip
./package.json
./processing.js
./utils.js
(The buggy require is located in processing.js)
If I open the ZIP, node_modules/fluent-ffmpeg/* does exist.
I tried to include the module using:
require("./node_modules/fluent-ffmpeg/index")
require(__dirname + "./node_modules/fluent-ffmpeg/index")
require(process.env.LAMBDA_TASK_ROOT + "/node_modules/fluent-ffmpeg/index")
But none of these solved the problem. I also tried reinstalling node and npm on my machine, rm -rf node_modules and npm install (just in case).
Since Lambda runs Node 0.10.36, I also tried using this version on my machine to do the npm install, but that doesn't change anything either.
Help appreciated.
Thanks!
Solved. My development machine runs Windows 7, and that's apparently what caused the issue... Would be interested in the reasons, though.
Anyway, running npm install on a linux installation and uploading the code to Lambda did the trick.
Related
I have a Nestjs Application which I try to run in a docker container. It all worked fine just until recently where I get the error Parse Error: Missing expected CR after header value. I'm trying to make a http GET Request to a webserver of an IoT device. Furthermore this error occurs only when I run the server-app inside a docker container. When I run it locally on a windows or macos machine everything works fine.
I tried using different versions of nodejs in docker. 14, 16 and 18. This error always comes up, independent of which version I use. I have no idea how I could debug this error, since it only occurs when I serve the app inside a docker container.
This is my dockerfile:
FROM node:slim
RUN mkdir -p /app
WORKDIR /app
COPY src .
COPY package.json .
RUN apt update && apt install python3 make g++ -y
RUN npm install --force
EXPOSE 3000
CMD ["npm", "run", "start:dev"]
According to this issue, this was recently implemented in Node v14.20.0, v16.16.0 and v18.5.0. Apparently it fixes a vulnerability in the HTTP parser of earlier versions.
Comments below the issue suggest various workarounds if it's not possible to fix the client, the easiest of which seems to be to set the insecureHTTPParser flag to true when creating the HTTP server.
Alternatively, revert to an older minor version of each of the Node.js versions mentioned above.
I have this Dockerfile
FROM node:14
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "node", "app.mjs" ]
And I can successfully run
docker run hello-world
on my ubuntu 20.10 OS.
So I am assuming that docker is installed successfully.
But when I tried to run
docker build .
It gives me this error
This is not something with the npm. I can locally install the dependencies without any issue. I assume Dokcer can't access npm registry to pull the npm packages. Something to do with networks I guess.
How do I fix this issue?
This is my code
https://github.com/Enuri-Information-Systems/docker-test
Depending on the network configuration it could happen that you run into problems that the container is not able to connect to a server to download data. This can have various reasons and also depends on how you run docker.
One common thing is that your network requires the usage of a proxy. But only having the error message it is not possible to tell what the exact reason in your case is.
One solution to that problem is to specify the network mode. Adding --network host as an option should most of the time work.
So running your build command that way docker build --network=host . should work.
I am receiving the below error message when running npm install on a project:
#10 35.10 PhantomJS not found on PATH
#10 35.10 Unexpected platform or architecture: linux/arm64
#10 35.10 It seems there is no binary available for your platform/architecture
#10 35.10 Try to install PhantomJS globally
screenshot of terminal error
The problem is, I am not using a Linux OS, I am using Mac BigSur.
I have tried installing PhantomJS globally using HomeBrew. I also tried setting a path according to this article Installing PhantomJS on Mac
Like this:
"and add this line to this file: ~/.bash_profile:
export PATH=$HOME/phantomjs-2.1.1-macosx/bin:$PATH"
I also tried deleting node_modules and package-lock.json, then reinstalling.
Here is a screenshot of my package.json
Any help would be greatly appreciated! Thanks!
I was trying to build and run VSCode on my Ubuntu 17.10 using the following guide: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run
When I tried to install dependencies using yarn, it is giving me the following error:
error /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep: Command failed.
Exit code: 1
Command: node ./lib/postinstall.js
Arguments:
Directory: /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep
Output:
Unzipping to /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep/bin
And then it stops the process. How do I proceed?
I have a similar issue while installing Theia. The broken vscode-ripgrep installation caused it. Here is the ticket I submitted to vscode-ripgrep.
https://github.com/roblourens/vscode-ripgrep/issues/15
I am working through the tutorial on the jspm.io site
https://github.com/jspm/jspm-cli/wiki/Getting-Started
All works fine until I get to item 3, where I try to execute
jspm install jquery
and I get this error message
warn Error on getOverride for jspm:github, retrying (2).
ReferenceError: ui is not defined
at c:\Projects\Project1\node_modules\jspm\node_modules\jspm-registry\registry.js:157:5
nodejs is v0.12.0
npm is 2.5.1
jspm is 0.14.0
and this is on Windows 8.1
Does anyone have any clue what is causing this?
This looks like it was because there was an error while jspm was trying to create the local registry clone. Ensure you have git installed as git on your machine. Otherwise it may be a permissions issue.
This was a logging bug though - have fixed it with an update to the registry, so that the error should be slightly more useful next time if you update jspm.
I was getting a similar error with jspm but my problem was actually in how nodejs child_process.exec was calling the git command.
child_process.exec was running
C:\Windows\system32\cmd.exe /s /c "git clone --depth=1 github.com/jspm/registry.git .
However cmd.exe was still auto running commands set in the registry first. In my case the command changing the working folder. So the cwd was being overridden.
Check your registry settings for:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
If there is a command in there to set the drive of working folder it will cause the above error.
Also
With your working folder as c:\, try ruuning the following nodejs code:
var exec = require('child_process').exec;
exec('dir', { cwd: 'C:/windows/fonts' }, function(error, stdout, stderr) {
console.log('stdout: ' + stdout);
});
If it does not list the contents of the fonts folder then your problem is more likely with child_process.exec in node