使用Docker MacOS在终端中找不到-bash:npm:命令

时间:2017-11-30 02:24:09

标签: node.js docker npm

我昨天在MacOS上安装了Docker,想要运行npm并获得: -bash:npm:找不到命令

我需要做些什么才能让它正常工作? THX。

1 个答案:

答案 0 :(得分:1)

npm未安装在您正在使用的图片上。

您可以执行以下任一操作:

  1. 通过传统方式安装;取决于您正在使用的操作系统。

  2. 使用图片,例如official node image 预先安装它。

  3. 您可以通过以下方式使用#2:

    import java.awt.Color;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    
     /*
    
     -Used built in Math trig methods to accomodate angling...looked this up online
    
    
     https://stackoverflow.com/questions/30032635/java-swing-draw-a-line-at-a-specific-angle
    
    
    */
    
    
    
    public class Test extends JFrame {
    
        public Test() {
    
            setBounds(100, 100, 800, 600);  //sets the boundary for drawing
    
        }
    
        public void drawTree(Graphics g, int x1, int y1, double angle, int depth) {
    
            System.out.println("x");
    
            if (depth == 6){
                return; //base case here to prevent infinite recursion..
            }
            else {
    
    
                System.out.println("y1");
    
                //embedded portion '(Math.toRadians(angle) * depth * 10.0)'represents angle...
    
                int x2 = x1 + (int) (Math.cos(Math.toRadians(angle)) * depth * 10.0);  //vertical shift calculated using the Sine...PARSED to int because method drawLine() accepts only ints as params
                int y2 = y1 + (int) (Math.sin(Math.toRadians(angle)) * depth * 10.0);  //hor. shift calculated using the Cos..PARSED to int
    
    
              //  System.out.println("x2: " + x2);//will reflect the change in vertical shift
                //System.out.println("y2: " + y2);//will reflect change in hor. shift
    
                g.drawLine(x1, y1, x2, y2);//value x1 equals previous line...in other word, start at where previously left off
                // notice that the end point (x2 and y2) becomes starting point for each successive call
    
    
                drawTree(g, x2, y2, angle - 20, depth - 1); //DRAWS LEFT SIDE?
    
               // drawTree(g, x2, y2, angle + 20, depth - 1); //DRAWS RIGHT SIDE?
    
            }
    
    
    
            if (depth == 6){
                return; //base case here to prevent infinite recursion..
            }
            else {
    
    
                System.out.println("y2");
    
    
                int x2 = x1 + (int) (Math.cos(Math.toRadians(angle)) * depth * 10.0);  //vertical shift calculated using the Sine...PARSED to int because method drawLine() accepts only ints as params
                int y2 = y1 + (int) (Math.sin(Math.toRadians(angle)) * depth * 10.0);  //hor. shift calculated using the Cos..PARSED to int
    
    
               // System.out.println("x2: " + x2);//will reflect the change in vertical shift
                //System.out.println("y2: " + y2);//will reflect change in hor. shift
    
                g.drawLine(x1, y1, x2, y2);//value x1 equals previous line...in other word, start at where previously left off
                // notice that the end point (x2 and y2) becomes starting point for each successive call
    
    
               // drawTree(g, x2, y2, angle - 20, depth - 1); //DRAWS LEFT SIDE?
    
                drawTree(g, x2, y2, angle + 20, depth - 1); //DRAWS RIGHT SIDE?
    
            }
    
        }
    
    
    
    
        public void drawIteratively(Graphics g, int x1A, int y1A, int x1B, int y1B, double angleA, double angleB, int depthA, int depthB){
    
            while (depthA != 4) {
    
    
                int x2A = x1A + (int) (Math.cos(Math.toRadians(angleA)) * depthA * 10.0);
                int y2A = y1A + (int) (Math.sin(Math.toRadians(angleA)) * depthA * 10.0);
    
                g.drawLine(x1A, y1A, x2A, y2A);   //remember it must continue drawing from where it left off
    
                angleA = angleA - 20;
                depthA = depthA - 1;
    
                x1A = x2A;
                y1A = y2A;
    
            }
    
            while (depthA != 4) {
    
    
                int x2A = x1A + (int) (Math.cos(Math.toRadians(angleA)) * depthA * 10.0);
                int y2A = y1A + (int) (Math.sin(Math.toRadians(angleA)) * depthA * 10.0);
    
                g.drawLine(x1A, y1A, x2A, y2A);   //remember it must continue drawing from where it left off
    
                angleA = angleA - 20;
                depthA = depthA - 1;
    
                x1A = x2A;
                y1A = y2A;
    
            }
    
            /*
    
            while(depthB != 4){
    
    
                int x2B = x1B + (int) (Math.cos(Math.toRadians(angleB)) * depthB * 10.0);
                int y2B = y1B + (int) (Math.sin(Math.toRadians(angleB)) * depthB * 10.0);
    
                g.drawLine(x1B, y1B, x2B, y2B);
    
                angleB = angleB + 20;
                depthB = depthB - 1;
    
                x1B = x2B;
                y1B = y2B;
    
            }
            */
    
        }
    
    
    
    
    
    
        @Override
        public void paint(Graphics g) {
            g.setColor(Color.BLUE);
    
    
           //drawTree(g, 400, 400, -90, 9); //these values corresponding to original line aka trunk during initial method call
    
            drawIteratively(g, 400, 500, 400,500 ,-90 , -90, 9,9);
    
    
    
    
        }
    
        public static void main(String[] args) {
    
            new Test().setVisible(true);
    
        }
    }