Home
Support Forums

Build.command fails with named export error

Hello! I am having issues with a Netlify build.

The error is:

Failed to compile.
 ./node_modules/@shopify/react-i18n/build/esm/i18n.mjs
Can't import the named export 'TimeUnit' from non EcmaScript module (only default export is available)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The Netlify site name is https://silly-williams-0265e1.netlify.app/ but the build failed so you won’t find anything there.

Deploy log:

4:53:38 PM: Build ready to start
4:53:40 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
4:53:40 PM: build-image tag: v3.6.0
4:53:40 PM: buildbot version: e26592b49d9d56b21349effe1b8fab4d50845f11
4:53:40 PM: Building without cache
4:53:40 PM: Starting to prepare the repo for build
4:53:41 PM: No cached dependencies found. Cloning fresh repo
4:53:41 PM: git clone https://github.com/Shopify/core-deliver-prototypes
4:53:42 PM: Preparing Git Reference refs/heads/order-tasks
4:53:43 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI
4:53:43 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'CI=false && yarn build' versus 'yarn build' in the Netlify UI
4:53:43 PM: Starting build script
4:53:44 PM: Installing dependencies
4:53:44 PM: Python version set to 2.7
4:53:45 PM: v12.18.0 is already installed.
4:53:45 PM: Now using node v12.18.0 (npm v6.14.4)
4:53:45 PM: Started restoring cached build plugins
4:53:45 PM: Finished restoring cached build plugins
4:53:46 PM: Attempting ruby version 2.7.1, read from environment
4:53:47 PM: Using ruby version 2.7.1
4:53:47 PM: Using PHP version 5.6
4:53:47 PM: Started restoring cached node modules
4:53:47 PM: Finished restoring cached node modules
4:53:47 PM: Started restoring cached yarn cache
4:53:47 PM: Finished restoring cached yarn cache
4:53:47 PM: Installing yarn at version 1.22.4
4:53:47 PM: Installing Yarn!
4:53:47 PM: > Downloading tarball...
4:53:47 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.pUGgEbV9ib
4:53:47 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
4:53:47 PM:                                  Dload  Upload   Total   Spent    Left  Speed
4:53:48 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:53:48 PM:   0    80    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
4:53:48 PM: 100    80  100    80    0     0     74      0  0:00:01  0:00:01 --:--:--    74
4:53:49 PM:   0    93    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
4:53:49 PM: 100    93  100    93    0     0     66      0  0:00:01  0:00:01 --:--:-- 93000
4:53:49 PM: 100   643  100   643    0     0    385      0  0:00:01  0:00:01 --:--:--   385
4:53:49 PM: 100 1215k  100 1215k    0     0   578k      0  0:00:02  0:00:02 --:--:--  578k
4:53:49 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.pUGgEbV9ib.asc
4:53:49 PM: 100    84  100    84    0     0   3018      0 --:--:-- --:--:-- --:--:--  3018
4:53:49 PM: 100    97  100    97    0     0   1707      0 --:--:-- --:--:-- --:--:--  1707
4:53:49 PM: 100   647  100   647    0     0   7329      0 --:--:-- --:--:-- --:--:--  7329
4:53:49 PM: 100  1028  100  1028    0     0   7885      0 --:--:-- --:--:-- --:--:--  7885
4:53:49 PM: > Verifying integrity...
4:53:49 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
4:53:49 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
4:53:49 PM: gpg: WARNING: This key is not certified with a trusted signature!
4:53:49 PM: gpg:          There is no indication that the signature belongs to the owner.
4:53:49 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
4:53:49 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
4:53:49 PM: > GPG signature looks good
4:53:49 PM: > Extracting to ~/.yarn...
4:53:50 PM: > Adding to $PATH...
4:53:50 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
4:53:50 PM: Installing NPM modules using Yarn version 1.22.4
4:53:51 PM: yarn install v1.22.4
4:53:51 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
4:53:51 PM: [1/4] Resolving packages...
4:53:56 PM: [2/4] Fetching packages...
4:54:25 PM: info fsevents@2.1.3: The platform "linux" is incompatible with this module.
4:54:25 PM: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
4:54:25 PM: info fsevents@2.0.7: The platform "linux" is incompatible with this module.
4:54:25 PM: info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
4:54:25 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
4:54:25 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
4:54:25 PM: [3/4] Linking dependencies...
4:54:25 PM: warning "@shopify/react-graphql > @apollo/react-common@3.1.4" has unmet peer dependency "@types/react@^16.8.0".
4:54:25 PM: warning "@shopify/react-graphql > @apollo/react-common@3.1.4" has unmet peer dependency "apollo-utilities@^1.3.2".
4:54:25 PM: warning "@shopify/react-graphql > @apollo/react-hooks@3.1.5" has unmet peer dependency "@types/react@^16.8.0".
4:54:25 PM: warning " > graphql-typed@0.4.1" has unmet peer dependency "@types/graphql@^14.0.0".
4:54:25 PM: warning " > styled-components@5.2.1" has unmet peer dependency "react-is@>= 16.8.0".
4:54:25 PM: warning " > @shopify/eslint-plugin@39.0.3" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > @typescript-eslint/eslint-plugin@4.10.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > @typescript-eslint/parser@4.10.0" has unmet peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > babel-eslint@10.1.0" has unmet peer dependency "eslint@>= 4.12.1".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-config-prettier@6.14.0" has unmet peer dependency "eslint@>=3.14.1".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-babel@5.3.1" has unmet peer dependency "eslint@>=4.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-eslint-comments@3.2.0" has unmet peer dependency "eslint@>=4.19.1".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-import@2.22.1" has unmet peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-jest@24.1.0" has unmet peer dependency "eslint@>=5".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-jest-formatting@2.0.0" has unmet peer dependency "eslint@>=0.8.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-jsx-a11y@6.4.1" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-node@11.1.0" has unmet peer dependency "eslint@>=5.16.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-prettier@3.1.4" has unmet peer dependency "eslint@>=5.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-prettier@3.1.4" has unmet peer dependency "prettier@>=1.13.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-react@7.21.5" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-react-hooks@4.2.0" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-sort-class-members@1.8.0" has unmet peer dependency "eslint@>=0.8.0".
4:54:25 PM: warning "@shopify/eslint-plugin > @typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils@4.10.0" has unmet peer dependency "eslint@*".
4:54:25 PM: warning "@shopify/eslint-plugin > eslint-plugin-node > eslint-plugin-es@3.0.1" has unmet peer dependency "eslint@>=4.19.1".
4:54:44 PM: [4/4] Building fresh packages...
4:54:47 PM: success Saved lockfile.
4:54:47 PM: $ npm run update-schema
4:54:47 PM: npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1609977285483-0.2857596045574611/node but npm is using /opt/buildhome/.nvm/versions/node/v12.18.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
4:54:47 PM: > core-deliver-prototypes@0.1.0 update-schema /opt/build/repo
4:54:47 PM: > babel-node --extensions .ts,.tsx,.mjs,.js,.json scripts/update-schema.ts
4:54:49 PM: [Error: ENOENT: no such file or directory, open '/opt/build/repo/src/graphql/schema.graphql'] {
4:54:49 PM:   errno: -2,
4:54:49 PM:   code: 'ENOENT',
4:54:49 PM:   syscall: 'open',
4:54:49 PM:   path: '/opt/build/repo/src/graphql/schema.graphql'
4:54:49 PM: }
4:54:49 PM: Done in 58.34s.
4:54:49 PM: NPM modules installed using Yarn
4:54:49 PM: Started restoring cached go cache
4:54:49 PM: Finished restoring cached go cache
4:54:49 PM: go version go1.14.4 linux/amd64
4:54:49 PM: go version go1.14.4 linux/amd64
4:54:49 PM: Installing missing commands
4:54:49 PM: Verify run directory
4:54:51 PM: ​
4:54:51 PM: ────────────────────────────────────────────────────────────────
4:54:51 PM:   Netlify Build                                                 
4:54:51 PM: ────────────────────────────────────────────────────────────────
4:54:51 PM: ​
4:54:51 PM: ❯ Version
4:54:51 PM:   @netlify/build 8.0.1
4:54:51 PM: ​
4:54:51 PM: ❯ Flags
4:54:51 PM:   deployId: 5ff64d82d81917008f376d0d
4:54:51 PM:   mode: buildbot
4:54:51 PM: ​
4:54:51 PM: ❯ Current directory
4:54:51 PM:   /opt/build/repo
4:54:51 PM: ​
4:54:51 PM: ❯ Config file
4:54:51 PM:   /opt/build/repo/netlify.toml
4:54:51 PM: ​
4:54:51 PM: ❯ Context
4:54:51 PM:   production
4:54:51 PM: ​
4:54:51 PM: ────────────────────────────────────────────────────────────────
4:54:51 PM:   1. build.command from netlify.toml                            
4:54:51 PM: ────────────────────────────────────────────────────────────────
4:54:51 PM: ​
4:54:51 PM: $ CI=false && yarn build
4:54:52 PM: yarn run v1.22.4
4:54:52 PM: $ react-scripts build
4:54:53 PM: Creating an optimized production build...
4:56:14 PM: Failed to compile.
4:56:14 PM: 
4:56:14 PM: ./node_modules/@shopify/react-i18n/build/esm/i18n.mjs
4:56:14 PM: Can't import the named export 'TimeUnit' from non EcmaScript module (only default export is available)
4:56:15 PM: error Command failed with exit code 1.
4:56:15 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4:56:15 PM: ​
4:56:15 PM: ────────────────────────────────────────────────────────────────
4:56:15 PM:   "build.command" failed                                        
4:56:15 PM: ────────────────────────────────────────────────────────────────
4:56:15 PM: ​
4:56:15 PM:   Error message
4:56:15 PM:   Command failed with exit code 1: CI=false && yarn build
4:56:15 PM: ​
4:56:15 PM:   Error location
4:56:15 PM:   In build.command from netlify.toml:
4:56:15 PM:   CI=false && yarn build
4:56:15 PM: ​
4:56:15 PM:   Resolved config
4:56:15 PM:   build:
4:56:15 PM:     command: CI=false && yarn build
4:56:15 PM:     commandOrigin: config
4:56:15 PM:     publish: /opt/build/repo/build
4:56:15 PM:   headers:
4:56:15 PM:     - for: /*      values:        Basic-Auth: impact:impact  redirects:    - force: false      from: /*      status: 200      to: /Caching artifacts
4:56:15 PM: Started saving node modules
4:56:15 PM: Finished saving node modules
4:56:15 PM: Started saving build plugins
4:56:15 PM: Finished saving build plugins
4:56:15 PM: Started saving yarn cache
4:56:15 PM: Finished saving yarn cache
4:56:15 PM: Started saving pip cache
4:56:15 PM: Finished saving pip cache
4:56:15 PM: Started saving emacs cask dependencies
4:56:15 PM: Finished saving emacs cask dependencies
4:56:15 PM: Started saving maven dependencies
4:56:15 PM: Finished saving maven dependencies
4:56:15 PM: Started saving boot dependencies
4:56:15 PM: Finished saving boot dependencies
4:56:15 PM: Started saving rust rustup cache
4:56:15 PM: Finished saving rust rustup cache
4:56:15 PM: Started saving rust cargo bin cache
4:56:15 PM: Finished saving rust cargo bin cache
4:56:15 PM: Started saving go dependencies
4:56:15 PM: Finished saving go dependencies
4:56:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:56:18 PM: Failing build: Failed to build site
4:56:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:56:18 PM: Finished processing build request in 2m37.781201867s

Build settings:

Base directory: Not set
Build command: CI=false && yarn build
Publish directory: build/
Builds: Active

This is the problem with the dependency and it probably won’t even be building locally, does it?

This issue is more suited here: https://github.com/Shopify/quilt/issues

As you can see, there’s already a similar open issue: https://github.com/Shopify/quilt/issues/1718. You’d get help faster from there.

Thanks for the response!

It does build locally, even with a fresh clone of the repo.

Kindly share the repo then for someone to be able to check it.

As it is a private repository, I can’t share it. Although I can paste anything useful here, such as the package.json or relevant information.

A bare minimum setup might help too. One that has your package.json and source of the file that’s giving the problem. If the problem lies only in the import statement, just add that much. Basically, a minimal setup having same error as yours.

Thank you so much for your help.

I decided to remove the package and re-work the code to work without it. This resolved the build error.

1 Like

I found a specific situation that creates this message, and an actual solution (as opposed to a dodge):

When a module is imported from the same directory as a named file:

import "aModuleIWant" from "./theModuleIWant";

-Directory
-|-index.mjs
-|-theModuleIWant.mjs

the transpiler gets confused as to whether the requested file is actually a module. A simple solution seems to be to move the module to a sub-directory:

-Directory
-|-index.mjs
-|-theModuleIWant
-|-|-index.mjs

Which works, and eliminates the warning.

Tracy Hall β€œleaddreamer”