代码之家  ›  专栏  ›  技术社区  ›  tm1701

Jenkins(在Docker容器中)-npm安装失败,因为…npm WARN tar ENOUNT:没有这样的文件或目录,请稍候

  •  7
  • tm1701  · 技术社区  · 7 年前

    在Jenkins Docker容器中运行“npm安装”时,我会遇到以下错误:

    [INFO] --- exec-maven-plugin:1.6.0:exec (npm install) @ geosolutions ---
    npm WARN tar ENOENT: no such file or directory, open '/var/jenkins_home/workspace/aproject2/node_modules/.staging/schema-utils-bdceae78/package.json'
    npm WARN tar ENOENT: no such file or directory, open '/var/jenkins_home/workspace/aproject2/node_modules/.staging/schema-utils-bdceae78/README.md'
    ...(and many lines like) ...
    npm WARN tar ENOENT: no such file or directory, futime
    npm WARN tar ENOENT: no such file or directory, futime
    npm WARN tar ENOENT: no such file or directory, futime
    npm WARN tar ENOENT: no such file or directory, futime
    

    进入Jenkins Docker容器时,我可以通过手动执行以下操作来解决此问题:

    • rm-射频节点单元模块
    • rm-f package-lock.json
    • npm安装

    下次我必须跳过“npm安装”步骤时,请直接从“ng构建”开始。然后一切正常。当然,这不是一个体面的解决办法。 因此,这不是一个重复的问题。

    如何进行良好的“npm安装”?

    在我的Jenkins容器中,我安装了Node/Npm。Npm为6.5,节点为8、9、10或11。全部采用最新的npm 6.5。

    My Jenkins图像包含将npm/NodeJ添加到其中的代码:

    RUN apt-get install -y curl \
      && curl -sL https://deb.nodesource.com/setup_9.x | bash - \
      && apt-get install -y nodejs \
      && curl -L https://www.npmjs.com/install.sh | sh
    

    今天我在办公室也遇到了同样的问题。两个不同的JenkinsJob使用“npm安装”启动相同的Maven任务。一个还好,另一个不行。一个作业通过多分支启动,另一个作为常规管道启动。嗯,很奇怪。

    我认为这与操作环境有关,因此$PATH、环境变量等等。

    1 回复  |  直到 7 年前
        1
  •  6
  •   tm1701    7 年前

    在与许多专家交谈并阅读了大量论坛帖子后,以下是建议的“解决方法”。许多人使用这种变通方法。我希望你有一个比这个更好的解决方案。至少,这种变通方法是有效的。

    按照解决方法,在Maven中构建Angular可以如下:首先清除工作区,特别是删除node_modules文件夹和package-lock.json文件。然后启动npm安装和构建操作。

    如果您在创建第一个构建之后很匆忙,只需添加属性“maven.exec.skip”,并使用-pmaven.exec.skip=true启动maven。然后跳过清洗和npm安装步骤;-)

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>npm clear workspace</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
              <skip>${maven.exec.skip}</skip>
              <executable>rm</executable>
              <arguments>
                <argument>-rf</argument>
                <argument>node_modules</argument>
                <argument>package-lock.json</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm install</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
              <skip>${maven.exec.skip}</skip>
              <executable>npm</executable>
              <arguments>
                <argument>install</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>build Angular production code</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <executable>npm</executable>
              <arguments>
                <argument>run</argument>
                <argument>build</argument>
                <!--<argument>&#45;&#45;prod</argument>-->
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    
        2
  •  0
  •   Kumar Pankaj Dubey    4 年前

    面对同样的问题,请采取步骤解决您的问题。

    npm WARN tar ENOUNT:没有这样的文件或目录

    用于解决以下问题的步骤:- 一) 在詹金斯的工作中,转到你的目录并

    rm-rf package-lock.json

    npm-i