Проблемы С установкой NPM

#angular #maven #npm

Вопрос:

Я использую Angular и NPM. Это мой пакет.json:

 {
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~11.2.5",
    "@angular/cdk": "^11.2.4",
    "@angular/common": "~11.2.5",
    "@angular/compiler": "~11.2.5",
    "@angular/core": "~11.2.5",
    "@angular/forms": "~11.2.5",
    "@angular/localize": "^11.2.5",
    "@angular/material": "^11.2.4",
    "@angular/platform-browser": "~11.2.5",
    "@angular/platform-browser-dynamic": "~11.2.5",
    "@angular/router": "~11.2.5",
    "@fortawesome/angular-fontawesome": "^0.8.2",
    "@fortawesome/fontawesome-common-types": "^0.2.34",
    "@fortawesome/fontawesome-svg-core": "^1.2.34",
    "@fortawesome/free-regular-svg-icons": "^5.15.2",
    "@fortawesome/free-solid-svg-icons": "^5.15.2",
    "@ng-bootstrap/ng-bootstrap": "^9.0.2",
    "@stomp/ng2-stompjs": "^8.0.0",
    "angular-oauth2-oidc": "^10.0.3",
    "bootstrap": "^4.6.0",
    "chart.js": "^2.9.4",
    "concurrently": "^6.0.0",
    "fontawesome": "^5.6.3",
    "jquery": "^3.6.0",
    "json-server": "^0.16.3",
    "ol": "^6.5.0",
    "popper.js": "^1.16.1",
    "primeicons": "^4.1.0",
    "primeng": "^11.3.0",
    "quill": "^1.3.7",
    "rxjs": "~6.6.6",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1102.4",
    "@angular/cli": "~11.2.4",
    "@angular/compiler-cli": "~11.2.5",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.19.14",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.1.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }
}
 

npm -версия: 6.14.11

версия ng:

 angelo@immediata:~/angular_repos/diomedee/front-end-diomedee$ ng version

     _                      _                 ____ _     ___
    /    _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △  | '_  / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ | | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   __| |_|__, |__,_|_|__,_|_|       ____|_____|___|
                |___/
    

Angular CLI: 11.2.4
Node: 12.21.0
OS: linux x64

Angular: 11.2.5
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.4
@angular-devkit/build-angular   0.1102.4
@angular-devkit/core            11.2.4
@angular-devkit/schematics      11.2.4
@angular/cdk                    11.2.4
@angular/cli                    11.2.4
@angular/material               11.2.4
@schematics/angular             11.2.4
@schematics/update              0.1102.4
rxjs                            6.6.6
typescript                      4.0.7
 

Я использую ubuntu 20 в качестве операционной системы

If I run npm install as user angelo, all works pretty good. If I run npm install as root user I get this error:

 root@immediata:~/.jenkins/workspace/diomedee/front-end-diomedee# npm install --save @fortawesome/fontawesome-free
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14  and could be using insecure binaries. Upgrade to fsevents 2.

> @fortawesome/fontawesome-common-types@0.2.34 postinstall /root/.jenkins/workspace/diomedee/front-end-diomedee/node_modules/@fortawesome/fontawesome-svg-core/node_modules/@fortawesome/fontawesome-common-types
> node attribution.js

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '/root/.jenkins/workspace/diomedee/front-end-diomedee/node_modules/@fortawesome/fontawesome-svg-core/node_modules/@fortawesome/fontawesome-common-types/attribution.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
 

I’m stucked on this error from 3 days… May anybody give me a tip on how to solve it?

Moreover the same thing happens also when I use maven-front-end-plugin. With user angelo all woarks good
With root it gives to me error.

UPDATE

После долгой отладки и после того, как я установил подробный уровень журнала npm, я обнаружил, что проблема связана с тем фактом, что я выполняю задание от имени пользователя root. Я нашел эту статью https://geedew.com/What-does-unsafe-perm-in-npm-actually-do/ и все работало довольно хорошо после того, как я изменил свой файл pom таким образом (я просто поместил раздел плагинов):

 <plugins>
   <plugin>
      <artifactId>maven-clean-plugin</artifactId>
      <version>3.1.0</version>
      <configuration>
         <filesets>
            <fileset>
               <directory>dist</directory>
               <includes>
                  <include>*</include>
                  <include>**/*</include>
               </includes>
            </fileset>
         </filesets>
      </configuration>
   </plugin>
   <plugin>
      <groupId>com.github.eirslett</groupId>
      <artifactId>frontend-maven-plugin</artifactId>
      <version>1.11.2</version>
      <executions>
         <execution>
            <id>install node and npm</id>
            <goals>
               <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
               <nodeVersion>v14.16.0</nodeVersion>
               <arguments>run build</arguments>
               <npmInheritsProxyConfigFromMaven>true</npmInheritsProxyConfigFromMaven>
            </configuration>
         </execution>
         <execution>
            <id>set npm registry</id>
            <goals>
               <goal>npm</goal>
            </goals>
            <configuration>
               <arguments>config set unsafe-perm true</arguments>
            </configuration>
         </execution>
         <execution>
            <id>npm install</id>
            <goals>
               <goal>npm</goal>
            </goals>
            <!-- optional: default phase is "generate-resources" -->
            <phase>generate-resources</phase>
            <configuration>
               <arguments>install</arguments>
            </configuration>
         </execution>
         <execution>
            <id>npm run build</id>
            <goals>
               <goal>npm</goal>
            </goals>
            <configuration>
               <arguments>run build</arguments>
               <npmInheritsProxyConfigFromMaven>true</npmInheritsProxyConfigFromMaven>
            </configuration>
         </execution>
      </executions>
   </plugin>
</plugins>
 

Самое главное-это <arguments>config set unsafe-perm true</arguments>

Я надеюсь, что это может быть полезно

Анджело

Комментарии:

1. Вы запускаете его из той же папки? (Может быть, какой-то местный нпм)

2. Я отладил… похоже, что все зависит от этого geedew.com/What-does-unsafe-perm-in-npm-actually-do Я установил эту конфигурацию, и, похоже, все в порядке. Я подожду в другой раз и отвечу на свой вопрос