issue in building snap with node18.17.0 version

I am building snap with node version 16.17.0 it works fine. but when I change the node version to 18.17.0 and build the snap app I got following issue. 

 

 

+ tar xzf - -C /home/boschrexroth/projects/mairotech/parts/mariotech/install/ --no-same-owner --strip-components=1
+ npm config set unsafe-perm true
npm ERR! `unsafe-perm` is not a valid npm option

npm ERR! A complete log of this run can be found in: /home/boschrexroth/.npm/_logs/2023-12-12T05_57_41_208Z-debug-0.log
Failed to build 'mariotech'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.



 

and this is my snapcraft.yaml file

name: mariotech
version: "1.0.0"
summary: mariotech project
description: |
  Programm is for showing web page of mariotech. Enter 'sudo snap logs ctrlx-node-hello-world.app -f | more' to see the output.
confinement: strict
#confinement: devmode
#icon: assets/icons/ICONHERE.png
grade: stable # must be 'stable' to release into candidate/stable channels
base: core20
type: app

apps:
  mariotech:
    command: bin/app
    daemon: simple
    # interfaces to connect to https://snapcraft.io/docs/supported-interfaces
    plugs:
      - network
      - network-bind
      - network-status
      - active-operation
      - datalayer
    slots:
      - package-assets
      - package-run
    restart-condition: always
    passthrough:
      restart-delay: 10s

parts:
  mariotech:
    plugin: npm
    source: .
    npm-node-version: "18.17.0"
  configs:
    plugin: dump
    source: ./configs
    organize:
      'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/

  www:
    plugin: dump
    source: ./www
    organize:
      '*': www/
     
slots:
  package-assets:
    interface: content
    content: package-assets
    source:
      read:
        - $SNAP/package-assets/${SNAPCRAFT_PROJECT_NAME}
  package-run:
    interface: content
    content: package-run
    source:
      write:
      - $SNAP_DATA/package-run/${SNAPCRAFT_PROJECT_NAME}

  plugs:
    active-solution:
      interface: content
      content: solutions
      target: $SNAP_COMMON/solutions
    datalayer:
      interface: content
      content: datalayer
      target: $SNAP_DATA/.datalayer
    build-environment:
      # Set the node version here. We recommend to use the latest LTS version.
      - NODE_VERSION: "18.17.0"

    # We don't use the npm plugin here, because it has no X-build capability (can't build arm64 target snaps on amd64).
 
    override-build: |
     
      # set target arch
      if [ $SNAPCRAFT_TARGET_ARCH == "arm64" ]; then
          arch="arm64"
      else
          arch="x64"
      fi    

      # fetch node
      echo fetching: $node_uri

      if [ ! -f "${SNAPCRAFT_PART_INSTALL}/bin/node" ]; then
          curl $node_uri | tar xzf - -C $SNAPCRAFT_PART_INSTALL/ --no-same-owner --strip-components=1
      fi
      # clean cache
      npm cache clean --force

      # install production dependencies
      npm install --production --ignore-scripts --no-fund --unsafe-perm

      # install nodemon as a development dependency
      npm install --save-dev nodemon

      # pack and install the app (only production)
      npm install -g --prefix $SNAPCRAFT_PART_INSTALL $(npm pack . | tail -1) --ignore-scripts --omit=dev --no-fund --unsafe-perm

      # remove unused node_modules
      rm -rf ${SNAPCRAFT_PART_INSTALL}/lib/node_modules/npm
      rm -rf ${SNAPCRAFT_PART_INSTALL}/lib/node_modules/corepack
                                   

 

11 replies