Yarn command "develop" not found - node.js

For reference, the goal is to design a blog website on github using .mdx format.
I'm trying to run a prebuilt docker container (I did not compose the image) using an M1 Mac. For ambiguity's sake - let's say the container image is called "docker run -it -p "8881:8000" -v "$PWD:/app" "xxxxxxxx/yyy-zzz-purpose-of-container". One of the container dependencies is yarn, as can be seen from the output. Also, the yarn command "develop" is erroring as not found. Aside from the seemingly inocuous license output, the CLI displays:
warning package.json: No license field error Command "develop" not found.
I then tried to run it natively without the docker image as a node.js sequence of commands, and received the same error.
nvm install --lts="Gallium"
nvm alias default 'lts/Gallium'
npm install -g npm
npm install -g gatsby-cli
npm install -g yarn
yarn install .
yarn run develop
I get the same error as with the container.

Related

npm install failing in alpine based docker image

I'm trying to run a node server in an Alpine based Docker image. However, it's failing on npm install. I would appreciate some help in figuring out what the issue is. Here is the Dockerfile
Here is the error when 'npm install' tries to run
One of your project depedencies requires an X window development package libXext which is not being install in your apk add... command.
Add the libxext-dev Alpine package, for instance.

How to use npm install with docker? Installing node_modules without installing npm

I' m trying to run npm install without installing npm:
sudo docker run -it -v $PWD/../src:/usr/src/app node:latest npm install
However I don't know where the WORKDIR of node:latest is located. I want node_modules installed in the folder $PWD/../src. I also don't want to create a dockerfile just for that.
This is actually a valid use case for using Docker where you just want to have a quick temporary environment to execute your scripts.
In case you do not know the WORKDIR of any image, you can still overwrite it when creating the container as described here.
sudo docker run --rm -it \
-w /any/directory \
-v $PWD/../src:/any/directory \
node:latest \
npm install
NOTE I added the flag --rm so that the container will automatically be cleaned up once the npm install command finishes running.

Local Npm module "jshint-stylish" not found. Is it installed?

Hi I am building docker image from node js project.
docker files contents are like below
fetch code from git repo.
install npm
install grunt cli
grunt build
please see below docker file
FROM ubuntu:latest
# Install Node.js and npm
RUN apt-get -y update
RUN apt-get -y install nodejs npm git wget curl
RUN git config --global http.sslverify false
WORKDIR /somerepo/
RUN git clone -somerepo
WORKDIR /somerepo/src/
RUN npm cache clean -f
RUN npm install -g n
RUN n stable
RUN npm install
RUN npm install -g grunt-cli
RUN grunt build
EXPOSE 3000
CMD ["node", "web.js"]
but its grunt build step is failing below error in logs
Step 14/15 : RUN grunt build
---> Running in d0f8863081f1
Local Npm module "jshint-stylish" not found. Is it installed?
Running "clean:dist" (clean) task
...
...
...
Running "githooks:all" (githooks) task
Binding jsbeautifier:pregit to pre-commit Git hook.
OK
Running "jshint:dev" (jshint) task
Warning: The "path" argument must be of type string. Received type object Use --force to continue.
Do any have any idea why grunt build is not ending successufully ?
I have already tried --save-dev option and also tried manually installing jshint with below command
#RUN npm install --save-dev jshint-stylish
Also i tried to print the files/directories having pattern "jshint" with below command in dockerfile
RUN find . -name "*jshint*"
and its printing below output in logs
Step 13/15 : RUN find . -name "*jshint*"
---> Running in db355c19f75a
./node_modules/.bin/jshint
./node_modules/ascii-table/.jshintrc
./node_modules/bl/.jshintrc
./node_modules/errno/.jshintrc
./node_modules/escodegen/.jshintrc
./node_modules/estraverse/.jshintrc
./node_modules/exit/.jshintrc
./node_modules/findup-sync/.jshintrc
./node_modules/gaze/.jshintrc
./node_modules/getobject/.jshintrc
./node_modules/globule/.jshintrc
./node_modules/grunt-contrib-clean/.jshintrc
./node_modules/grunt-contrib-compress/.jshintrc
./node_modules/grunt-contrib-concat/.jshintrc
./node_modules/grunt-contrib-cssmin/.jshintrc
./node_modules/grunt-contrib-jshint
./node_modules/grunt-contrib-jshint/tasks/jshint.js
./node_modules/grunt-contrib-jshint/tasks/lib/jshint.js
./node_modules/grunt-contrib-uglify/.jshintrc
./node_modules/grunt-contrib-watch/.jshintrc
./node_modules/grunt-express-server/.jshintrc
./node_modules/grunt-git-describe/.jshintrc
./node_modules/grunt-githooks/.jshintrc
./node_modules/grunt-img/node_modules/.bin/jshint
./node_modules/grunt-img/node_modules/grunt-contrib-jshint
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/.jshintrc
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-examples.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-options.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-overview.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/tasks/jshint.js
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/test/jshint_test.js
./node_modules/grunt-img/node_modules/jshint
./node_modules/grunt-img/node_modules/jshint/packages/jshint
./node_modules/grunt-img/node_modules/jshint/packages/jshint/jshint.js
./node_modules/grunt-jsbeautifier/.jshintrc
./node_modules/grunt-json-replace/.jshintrc
./node_modules/grunt-legacy-log/.jshintrc
./node_modules/grunt-legacy-log-utils/.jshintrc
./node_modules/grunt-legacy-util/.jshintrc
./node_modules/grunt-lib-contrib/.jshintrc
./node_modules/grunt-manifest/.jshintrc
./node_modules/grunt-prettify/.jshintrc
./node_modules/grunt-sloc/.jshintrc
./node_modules/grunt-sloccount/.jshintrc
./node_modules/grunt-text-replace/.jshintrc
./node_modules/handlebars/.jshintrc
./node_modules/ibrik/node_modules/estraverse/.jshintrc
./node_modules/isstream/.jshintrc
./node_modules/istanbul/node_modules/estraverse/.jshintrc
./node_modules/jshint
./node_modules/jshint/bin/jshint
./node_modules/jshint/src/jshint.js
./node_modules/jshint-stylish
./node_modules/keep-alive-agent/.jshintrc
./node_modules/less/.idea/jsLinters/jshint.xml
./node_modules/less/.jshintrc
./node_modules/log4js/.jshintrc
./node_modules/nodemon/.jshintrc
./node_modules/phantomjs/.jshintrc
./node_modules/promise/.jshintrc
./node_modules/prr/.jshintrc
./node_modules/request-progress/.jshintrc
./node_modules/resolve-url/.jshintrc
./node_modules/restify/node_modules/qs/.jshintignore
./node_modules/restify/node_modules/qs/.jshintrc
./node_modules/save/.jshintignore
./node_modules/save/.jshintrc
./node_modules/shelljs/jshint.json
./node_modules/source-map-resolve/.jshintrc
./node_modules/source-map-url/.jshintrc
./node_modules/undefsafe/.jshintrc
./node_modules/urix/.jshintrc
./node_modules/xtend/.jshintrc
if anyone have any idea what is wrong please let me know
Thanks in advance !!!

docker npm install serve fails

I'm not very familiar to docker, but I'm trying to put the frontend (written with create-react-app) into the docker container.
I've found a tutorial and followed it, so my Dockerfile looks like this:
FROM node:7.8.0
ENV NPM_CONFIG_LOGLEVEL warn
RUN npm install -g serve
CMD serve -s --port 8081 build
EXPOSE 8081
COPY package.json package.json
COPY npm-shrinkwrap.json npm-shrinkwrap.json
RUN npm install
COPY . .
RUN npm run build --production
In my machine it works ok, but when I try to put it on server (raspberry pi) with docker-compose it fails.
Step 3 : RUN npm install -g serve
ERROR: Service 'frontend' failed to build: rpc error: code = 2 desc = "oci runtime error: exec format error"
I've googled, but haven't found exactly this problem. I even tried to put sudo before npm install, but got an error
/bin/sh: 1: sudo: not found
You can either create your private repository locally or can push it to docker-hub and then try loading it on raspberry-pi.

Docker Compose w/ Gulp - Local gulp not found

I am attempting to use gulp inside a Docker container.
I have the following Dockerfile
FROM golang:alpine
RUN apk --update add --no-cache git nodejs
RUN npm install --global gulp
ENV GOPATH=/go PATH=$PATH:/go/bin
VOLUME ["/go/src/github.com/me/sandbox", "/go/pkg","/go/bin"]
WORKDIR /go/src/github.com/me/sandbox
CMD ["gulp"]
and I have the following docker-compose.yml
version: '2'
services:
service:
build: ./service
volumes:
- ./service/src/:/go/src/github.com/me/sandbox
docker-compose build builds successfully, but when I run docker-compose up, I get the following error message
Recreating sandbox_service_1
Attaching to sandbox_service_1
service_1 | [22:03:40] Local gulp not found in /go/src/github.com/me/sandbox
service_1 | [22:03:40] Try running: npm install gulp
I have tried several different things to try to fix it.
Tried also installing gulp-cli globally and locally
Tried installing gulp locally with npm install gulp
Tried moving the npm install --global gulp after the WORKDIR
Tried different paths for volumes.
My guess is that it has something to do with the volumes, because when I get rid of anything having to do with a volume, it doesn't complain.
Mr project structure is shown in screenshot below:
This is what worked for me.
RUN npm install -g gulp
RUN npm link gulp
You need a local version of gulp as well as a global one.
Adding this line should fix your issue
RUN npm i gulp

Resources