简体   繁体   中英

Jenkins (in a Docker container) - npm install fails because of ... npm WARN tar ENOENT: no such file or directory, futime

When running 'npm install' in a Jenkins Docker container I get these errors:

 [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

No 'node_modules' are generated. Only a few in node_modules/.staging.

When going into the Jenkins Docker container, I can fix this by manually performing:

  • rm -rf node_modules
  • rm -f package-lock.json
  • npm install

The next time I have to skip the 'npm install' step, so directly start with the 'ng build'. Then everything works OK. Of couse - this is not a decent workaround. Therefore this is NOT a duplicate question.

How can I do a good 'npm install'?

In my Jenkins container I have a Node/Npm installation. Npm is 6.5 and node is either 8, 9, 10 or 11. All with the newest npm 6.5.

My Jenkins image contains this code for adding npm/nodejs to it:

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

Update: Today I had the same issue at the office. Two different Jenkinsjobs start the very same Maven task with 'npm install'. One is OK, the other not. One Jenkinsjob is started via a multibranch, the other as a regular pipeline. Hmm, very strange.

I think this has to do with the operating environment, so the $PATH, environment variables, etc.

After talking to a number of experts and reading a lot of forum posts, the following is the proposed 'workaround'. Many people use the workaround. I hope you have a better solution than this one. At least, this workaround works.

Following the workaround, building Angular in Maven can go like this: first clear the workspace, especially removing the node_modules folder and the package-lock.json file. Then start the npm install and the build action.

If you are in a hurry after creating your first build, just add a property 'maven.exec.skip', and start Maven with the -P maven.exec.skip=true. Then the cleaning and npm install step are skipped ;-)

<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>

Facing the Same Issue steps to resolve your issue.

npm WARN tar ENOENT: no such file or directory

steps used to solve:- I) in Jenkins job go to your directory and do

rm -rf package-lock.json

npm -i

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM