Building NodeJS app snap and needed build folder is missing in staging step

I am trying to use snap for the first time to package a NodeJS app. Everything seems pretty simple except that symlinks are broken in the stage and prime step because a build folder is not copied during from the parts folder.

name: chuck
version: test
summary: Command line weather tool.
confinement: devmode
description: foobar

parts:
  command:
    plugin: nodejs
    node-engine: 8.12.0
    source: .
    build-packages:
    - python
    - build-essential

apps:
  chuck:
    command: bin/chuck
root@7241861fba6e:/tmp/app# tree -L 3 parts
parts
└── command
    β”œβ”€β”€ build
    β”‚   β”œβ”€β”€ LICENSE
    β”‚   β”œβ”€β”€ README.md
    β”‚   β”œβ”€β”€ app.js
    β”‚   β”œβ”€β”€ ci_scripts
    β”‚   β”œβ”€β”€ config
    β”‚   β”œβ”€β”€ dist
    β”‚   β”œβ”€β”€ gulpfile.js
    β”‚   β”œβ”€β”€ lib
    β”‚   β”œβ”€β”€ node_modules
    β”‚   β”œβ”€β”€ package-lock.json
    β”‚   β”œβ”€β”€ package.json
    β”‚   β”œβ”€β”€ scripts
    β”‚   β”œβ”€β”€ test
    β”‚   └── tsconfig.json
    β”œβ”€β”€ install
    β”‚   β”œβ”€β”€ CHANGELOG.md
    β”‚   β”œβ”€β”€ LICENSE
    β”‚   β”œβ”€β”€ README.md
    β”‚   β”œβ”€β”€ bin
    β”‚   β”œβ”€β”€ include
    β”‚   β”œβ”€β”€ lib
    β”‚   └── share
    β”œβ”€β”€ npm
    β”‚   └── node-v8.12.0-linux-x64.tar.gz
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ LICENSE
    β”‚   β”œβ”€β”€ README.md
    β”‚   β”œβ”€β”€ app.js
    β”‚   β”œβ”€β”€ ci_scripts
    β”‚   β”œβ”€β”€ config
    β”‚   β”œβ”€β”€ dist
    β”‚   β”œβ”€β”€ gulpfile.js
    β”‚   β”œβ”€β”€ lib
    β”‚   β”œβ”€β”€ node_modules
    β”‚   β”œβ”€β”€ package-lock.json
    β”‚   β”œβ”€β”€ package.json
    β”‚   β”œβ”€β”€ scripts
    β”‚   β”œβ”€β”€ test
    β”‚   └── tsconfig.json
    └── state
        β”œβ”€β”€ build
        β”œβ”€β”€ prime
        β”œβ”€β”€ pull
        └── stage
root@7241861fba6e:/tmp/app# tree -L 3 stage
stage
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ bin
β”‚   β”œβ”€β”€ mfp_executive -> ../lib/node_modules/@sixriver/mfp_executive/dist/lib/app.js
β”‚   β”œβ”€β”€ node
β”‚   β”œβ”€β”€ npm -> ../lib/node_modules/npm/bin/npm-cli.js
β”‚   └── npx -> ../lib/node_modules/npm/bin/npx-cli.js
β”œβ”€β”€ include
β”‚   └── node
β”‚       β”œβ”€β”€ android-ifaddrs.h
β”‚       β”œβ”€β”€ common.gypi
β”‚       β”œβ”€β”€ config.gypi
β”‚       β”œβ”€β”€ libplatform
β”‚       β”œβ”€β”€ node.h
β”‚       β”œβ”€β”€ node_api.h
β”‚       β”œβ”€β”€ node_api_types.h
β”‚       β”œβ”€β”€ node_buffer.h
β”‚       β”œβ”€β”€ node_object_wrap.h
β”‚       β”œβ”€β”€ node_version.h
β”‚       β”œβ”€β”€ openssl
β”‚       β”œβ”€β”€ pthread-barrier.h
β”‚       β”œβ”€β”€ stdint-msvc2008.h
β”‚       β”œβ”€β”€ tree.h
β”‚       β”œβ”€β”€ uv-aix.h
β”‚       β”œβ”€β”€ uv-bsd.h
β”‚       β”œβ”€β”€ uv-darwin.h
β”‚       β”œβ”€β”€ uv-errno.h
β”‚       β”œβ”€β”€ uv-linux.h
β”‚       β”œβ”€β”€ uv-os390.h
β”‚       β”œβ”€β”€ uv-posix.h
β”‚       β”œβ”€β”€ uv-sunos.h
β”‚       β”œβ”€β”€ uv-threadpool.h
β”‚       β”œβ”€β”€ uv-unix.h
β”‚       β”œβ”€β”€ uv-version.h
β”‚       β”œβ”€β”€ uv-win.h
β”‚       β”œβ”€β”€ uv.h
β”‚       β”œβ”€β”€ v8-debug.h
β”‚       β”œβ”€β”€ v8-inspector-protocol.h
β”‚       β”œβ”€β”€ v8-inspector.h
β”‚       β”œβ”€β”€ v8-platform.h
β”‚       β”œβ”€β”€ v8-profiler.h
β”‚       β”œβ”€β”€ v8-testing.h
β”‚       β”œβ”€β”€ v8-util.h
β”‚       β”œβ”€β”€ v8-value-serializer-version.h
β”‚       β”œβ”€β”€ v8-version-string.h
β”‚       β”œβ”€β”€ v8-version.h
β”‚       β”œβ”€β”€ v8.h
β”‚       β”œβ”€β”€ v8config.h
β”‚       β”œβ”€β”€ zconf.h
β”‚       └── zlib.h
β”œβ”€β”€ lib
β”‚   └── node_modules
β”‚       β”œβ”€β”€ @sixriver
β”‚       └── npm
└── share
    β”œβ”€β”€ doc
    β”‚   └── node
    β”œβ”€β”€ man
    β”‚   └── man1
    └── systemtap
        └── tapset

So my question is what am I doing wrong… it seems to expect that the build directory would be there, but its unclear why in my simple case it is not when it has what seems to be all the important information.

Is this possibly a bug in the nodejs snapcraft plugin? Or does it have something to do with my setup specfifically?

Managed to answer my own question…

using NPM just doesn’t seem to work, when I changed to using yarn for snap, it created without an issue.

1 Like

I had a similar problem (NPM not working, forced to use yarn)