Deploy - Cannot use import statement outside a module

I set up a new project with some branch deploy, the deploy on itself seems to work well enough but the build seems to be broken for the api side.

This is a Typescript project, you will find below relevant files and the last deploy log.

The error I am getting seems to happen on any api call:

trace: ["Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",…]
0: "Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module"
1: "    at _loadUserApp (/var/runtime/UserFunction.js:98:13)"
2: "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"
3: "    at Object.<anonymous> (/var/runtime/index.js:43:30)"
4: "    at Module._compile (internal/modules/cjs/loader.js:999:30)"
5: "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"
6: "    at Module.load (internal/modules/cjs/loader.js:863:32)"
7: "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)"
8: "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"
9: "    at internal/main/run_main_module.js:17:47"

The react part works well.

I have seen a couple of other posts on such an error in the Netlify community posts but I don’t believe it applies to this project. Here would be relevant files, also to note, I set up successfully other RedwoodJS projects, those files were accordingly corrected to no success:

# netlify.toml
[build]
  command = "yarn rw deploy netlify"
  publish = "web/dist"
  functions = "api/dist/functions"

[dev]
  command = "yarn rw dev"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
# api/tsconfig.json
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "src/*": [
        "./src/*"
      ]
    },
    "types": [
      "./src/services/**/index.d.ts",
    ]
  },
  "exclude": [
    "./node_modules"
  ],
  "include": [
    "src"
  ]
}
#tsconfig.json
{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "composite": false,
    "declarationMap": false,
    "emitDeclarationOnly": false,
    "esModuleInterop": true,
    "jsx": "preserve",
    "lib": [
      "es7",
      "es6",
      "dom",
      "ES2020"
    ],
    "noEmit": true,
    "module": "esnext",
    "moduleResolution": "node",
    "pretty": true,
    "sourceMap": false,
    "target": "esnext",
    "strict": true,
    "strictNullChecks": true,
    "typeRoots": [
      ".redwood"
    ]
  },
  "include": [
    "./api/src",
    "./web/src"
  ],
  "exclude": [
    "node_modules"
  ]
}

The log:

12:04:13 PM: Build ready to start
12:04:15 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
12:04:15 PM: build-image tag: v3.7.0
12:04:15 PM: buildbot version: b8a7cb2ab30309dc791e77b97759136f817b5561
12:04:15 PM: Fetching cached dependencies
12:04:15 PM: Starting to download cache of 295.3MB
12:04:18 PM: Finished downloading cache in 2.465825623s
12:04:18 PM: Starting to extract cache
12:04:32 PM: Finished extracting cache in 14.164088022s
12:04:32 PM: Finished fetching cache in 16.758307559s
12:04:32 PM: Starting to prepare the repo for build
12:04:32 PM: Preparing Git Reference refs/heads/preview
12:04:34 PM: Parsing package.json dependencies
12:04:35 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/dist' versus '/' in the Netlify UI
12:04:35 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'api/dist/functions' versus '' in the Netlify UI
12:04:35 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'yarn rw deploy netlify' versus '' in the Netlify UI
12:04:35 PM: Starting build script
12:04:35 PM: Installing dependencies
12:04:35 PM: Python version set to 2.7
12:04:36 PM: Started restoring cached node version
12:04:39 PM: Finished restoring cached node version
12:04:39 PM: Attempting node version 'lts/*' from .nvmrc
12:04:40 PM: v14.16.0 is already installed.
12:04:40 PM: Now using node v14.16.0 (npm v6.14.11)
12:04:40 PM: Started restoring cached build plugins
12:04:40 PM: Finished restoring cached build plugins
12:04:41 PM: Attempting ruby version 2.7.1, read from environment
12:04:42 PM: Using ruby version 2.7.1
12:04:43 PM: Using PHP version 5.6
12:04:43 PM: Started restoring cached yarn cache
12:04:43 PM: Finished restoring cached yarn cache
12:04:43 PM: Started restoring cached node modules
12:04:43 PM: Finished restoring cached node modules
12:04:43 PM: Installing NPM modules using Yarn version 1.22.4
12:04:44 PM: yarn install v1.22.4
12:04:44 PM: [1/5] Validating package.json...
12:04:44 PM: [2/5] Resolving packages...
12:04:45 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
12:04:45 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
12:04:45 PM: warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3"
12:04:45 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
12:04:45 PM: warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3"
12:04:45 PM: [3/5] Fetching packages...
12:05:52 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
12:05:52 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
12:05:52 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
12:05:52 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
12:05:52 PM: [4/5] Linking dependencies...
12:05:52 PM: warning "@redwoodjs/core > @redwoodjs/testing > @redwoodjs/web > react-hot-toast > goober@2.0.33" has unmet peer dependency "csstype@^2.6.2".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router@1.3.4" has incorrect peer dependency "react@15.x || 16.x || 16.4.0-alpha.0911da3".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router@1.3.4" has incorrect peer dependency "react-dom@15.x || 16.x || 16.4.0-alpha.0911da3".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-helmet-async@1.0.7" has incorrect peer dependency "react@^16.6.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-helmet-async@1.0.7" has incorrect peer dependency "react-dom@^16.6.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-sizeme@2.6.12" has incorrect peer dependency "react@^0.14.0 || ^15.0.0-0 || ^16.0.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-sizeme@2.6.12" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0-0 || ^16.0.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router > create-react-context@0.3.0" has incorrect peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-popper-tooltip@2.11.1" has incorrect peer dependency "react@^16.6.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-popper-tooltip@2.11.1" has incorrect peer dependency "react-dom@^16.6.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-textarea-autosize@7.1.2" has incorrect peer dependency "react@>=0.14.0 <17.0.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > simplebar-react@1.2.3" has incorrect peer dependency "react@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
12:05:52 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > simplebar-react@1.2.3" has incorrect peer dependency "react-dom@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > @date-io/date-fns@1.3.13" has unmet peer dependency "date-fns@^2.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > @material-ui/pickers@3.2.10" has unmet peer dependency "@date-io/core@^1.3.6".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > @material-ui/pickers@3.2.10" has incorrect peer dependency "react@^16.8.4".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > @material-ui/pickers@3.2.10" has incorrect peer dependency "react-dom@^16.8.4".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > dexie-react-hooks@1.0.6" has unmet peer dependency "@types/react@>=16".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > sass-loader@10.1.1" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > postcss-loader@4.0.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > postcss-loader@4.0.2" has unmet peer dependency "postcss@^7.0.0 || ^8.0.1".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/addons@^5.0.0 || ^6.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/components@^5.0.0 || ^6.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/theming@^5.0.0 || ^6.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs > react-pdf@4.2.0" has incorrect peer dependency "react@^16.3.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs > react-pdf@4.2.0" has incorrect peer dependency "react-dom@^16.3.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > api > firebase-admin > @firebase/database > @firebase/auth-interop-types@0.1.5" has unmet peer dependency "@firebase/app-types@0.x".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs > react-pdf > pdfjs-dist@2.1.266" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > api > @redwoodjs/api > graphql-tools > @graphql-tools/links > apollo-upload-client@14.1.2" has unmet peer dependency "subscriptions-transport-ws@^0.9.0".
12:05:52 PM: warning "workspace-aggregator-f985cad3-97c8-4aca-897d-a58ea537610d > web > storybook-addon-designs > react-pdf > pdfjs-dist > worker-loader@2.0.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
12:06:35 PM: [5/5] Building fresh packages...
12:06:43 PM: Done in 119.64s.
12:06:44 PM: NPM modules installed using Yarn
12:06:44 PM: Started restoring cached go cache
12:06:44 PM: Finished restoring cached go cache
12:06:44 PM: go version go1.14.4 linux/amd64
12:06:44 PM: go version go1.14.4 linux/amd64
12:06:44 PM: Installing missing commands
12:06:44 PM: Verify run directory
12:06:46 PM: ​
12:06:46 PM: ────────────────────────────────────────────────────────────────
12:06:46 PM:   Netlify Build                                                 
12:06:46 PM: ────────────────────────────────────────────────────────────────
12:06:46 PM: ​
12:06:46 PM: ❯ Version
12:06:46 PM:   @netlify/build 9.11.4
12:06:46 PM: ​
12:06:46 PM: ❯ Flags
12:06:46 PM:   apiHost: api.netlify.com
12:06:46 PM:   cacheDir: /opt/build/cache
12:06:46 PM:   deployId: 6059cb2d30a857000796d70b
12:06:46 PM:   mode: buildbot
12:06:46 PM:   testOpts:
12:06:46 PM:     silentLingeringProcesses: ''
12:06:46 PM: ​
12:06:46 PM: ❯ Current directory
12:06:46 PM:   /opt/build/repo
12:06:46 PM: ​
12:06:46 PM: ❯ Config file
12:06:46 PM:   /opt/build/repo/netlify.toml
12:06:46 PM: ​
12:06:46 PM: ❯ Context
12:06:46 PM:   production
12:06:46 PM: ​
12:06:46 PM: ────────────────────────────────────────────────────────────────
12:06:46 PM:   1. build.command from netlify.toml                            
12:06:46 PM: ────────────────────────────────────────────────────────────────
12:06:46 PM: ​
12:06:46 PM: $ yarn rw deploy netlify
12:06:46 PM: yarn run v1.22.4
12:06:46 PM: $ /opt/build/repo/node_modules/.bin/rw deploy netlify
12:06:49 PM: $ /opt/build/repo/node_modules/.bin/rw build
12:06:51 PM: Generating the Prisma client... [started]
12:06:56 PM: Generating the Prisma client... [completed]
12:06:56 PM: [11:06:56] Cleaning "web"... (./web/dist/) [started]
12:06:56 PM: [11:06:56] Cleaning "web"... (./web/dist/) [completed]
12:06:56 PM: [11:06:56] Building "api"... [started]
12:07:01 PM: [11:07:01] Building "api"... [completed]
12:07:01 PM: [11:07:01] Building "web"... [started]
12:08:00 PM: [11:08:00] Building "web"... [completed]
12:08:00 PM: [11:08:00] Prerendering "web"... [started]
12:08:05 PM: [11:08:05] Prerendering "web"... [failed]
12:08:05 PM: [11:08:05] → Command failed with exit code 1: yarn rw prerender
12:08:05 PM: Could not resolve "/opt/build/repo/web/src/pages/FatalErrorPage" in file /opt/build/repo/web/src/App.js.
12:08:05 PM: error Command failed with exit code 1.
12:08:05 PM: $ /opt/build/repo/node_modules/.bin/rw prerender
12:08:05 PM: [11:08:03] Prerendering / -> web/dist/index.html [started]
12:08:05 PM: [11:08:05] Prerendering / -> web/dist/index.html [failed]
12:08:05 PM: [11:08:05] → document is not defined
12:08:05 PM: Running diagnostic checks
12:08:05 PM: ✔ Diagnostics checks passed
12:08:05 PM: Not all routes were succesfully prerendered. Run `yarn rw prerender --dry-run` for detailed logs
12:08:05 PM: We could not prerender all your pages, but your Redwood app should still work fine.
12:08:05 PM: This could mean that a library you're using does not support SSR.
12:08:05 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:08:05 PM: Command failed with exit code 1: yarn rw prerender
12:08:05 PM: Could not resolve "/opt/build/repo/web/src/pages/FatalErrorPage" in file /opt/build/repo/web/src/App.js.
12:08:05 PM: error Command failed with exit code 1.
12:08:05 PM: $ /opt/build/repo/node_modules/.bin/rw prerender
12:08:05 PM: [11:08:03] Prerendering / -> web/dist/index.html [started]
12:08:05 PM: [11:08:05] Prerendering / -> web/dist/index.html [failed]
12:08:05 PM: [11:08:05] → document is not defined
12:08:05 PM: 
12:08:05 PM: Running diagnostic checks
12:08:05 PM: ✔ Diagnostics checks passed 
12:08:05 PM: 
12:08:05 PM: Not all routes were succesfully prerendered. Run `yarn rw prerender --dry-run` for detailed logs
12:08:05 PM: We could not prerender all your pages, but your Redwood app should still work fine.
12:08:05 PM: This could mean that a library you're using does not support SSR.
12:08:05 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:08:05 PM: error Command failed with exit code 1.
12:08:05 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:08:05 PM: Done in 79.29s.
12:08:05 PM: ​
12:08:05 PM: (build.command completed in 1m 19.5s)
12:08:05 PM: ​
12:08:05 PM: ────────────────────────────────────────────────────────────────
12:08:05 PM:   2. Functions bundling                                         
12:08:05 PM: ────────────────────────────────────────────────────────────────
12:08:05 PM: ​
12:08:05 PM: Packaging Functions from api/dist/functions directory:
12:08:05 PM:  - graphql.js
12:08:05 PM: ​
12:08:47 PM: ​
12:08:47 PM: (Functions bundling completed in 41.6s)
12:08:47 PM: ​
12:08:47 PM: ────────────────────────────────────────────────────────────────
12:08:47 PM:   3. Deploy site                                                
12:08:47 PM: ────────────────────────────────────────────────────────────────
12:08:47 PM: ​
12:08:47 PM: Starting to deploy site from 'web/dist'
12:08:47 PM: Creating deploy tree 
12:08:47 PM: Creating deploy upload records
12:08:47 PM: 22 new files to upload
12:08:47 PM: 1 new functions to upload
12:08:54 PM: Site deploy was successfully initiated
12:08:54 PM: ​
12:08:54 PM: (Deploy site completed in 6.6s)
12:08:54 PM: ​
12:08:54 PM: ────────────────────────────────────────────────────────────────
12:08:54 PM:   Netlify Build Complete                                        
12:08:54 PM: ────────────────────────────────────────────────────────────────
12:08:54 PM: ​
12:08:54 PM: (Netlify Build completed in 2m 7.8s)
12:08:54 PM: Starting post processing
12:08:54 PM: Caching artifacts
12:08:54 PM: Started saving node modules
12:08:54 PM: Finished saving node modules
12:08:54 PM: Started saving build plugins
12:08:54 PM: Finished saving build plugins
12:08:54 PM: Started saving yarn cache
12:08:54 PM: Finished saving yarn cache
12:08:54 PM: Started saving pip cache
12:08:54 PM: Post processing - HTML
12:08:54 PM: Finished saving pip cache
12:08:54 PM: Started saving emacs cask dependencies
12:08:54 PM: Post processing - header rules
12:08:54 PM: Post processing - redirect rules
12:08:54 PM: Finished saving emacs cask dependencies
12:08:54 PM: Started saving maven dependencies
12:08:54 PM: Finished saving maven dependencies
12:08:54 PM: Started saving boot dependencies
12:08:54 PM: Finished saving boot dependencies
12:08:54 PM: Started saving rust rustup cache
12:08:54 PM: Finished saving rust rustup cache
12:08:54 PM: Started saving go dependencies
12:08:54 PM: Finished saving go dependencies
12:08:54 PM: Build script success
12:08:54 PM: Post processing done
12:08:54 PM: Site is live ✨
12:09:55 PM: Finished processing build request in 5m40.469657435s

That’s a bit tricky to debug for a noob, not mentionning deploys for RW apps now take around 6-7 minutes - the free plan gets consumed fast!

@danny Is this the same error I once saw when setting up Prerender?

No I don’t believe this is related, although I can see prerender failing there on index. I think its probably a module that relies on document that doesn’t have the isBrowser check.

Anyway… I’m going to not distract any more here, as I don’t really have anything to help solve your main problem!

Guilty, I assume it is firebase. I didn’t dig further into it as prerendering was not implemented, just wildly tested on "/", it’s now removed and prerendering is skipped.

Main error still relevant though :slight_smile:

@peterp what do you think of it?

Update: for good measure, here’s the log without prerendering issues:

6:25:42 PM: Waiting for other deploys from your team to complete
6:25:43 PM: Build ready to start
6:25:46 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
6:25:46 PM: build-image tag: v3.7.0
6:25:46 PM: buildbot version: 945e22ac61fb3a0e5ec8bebfe91c852809f9f21b
6:25:46 PM: Fetching cached dependencies
6:25:46 PM: Starting to download cache of 295.4MB
6:25:53 PM: Finished downloading cache in 7.339003104s
6:25:53 PM: Starting to extract cache
6:26:10 PM: Finished extracting cache in 16.749746885s
6:26:10 PM: Finished fetching cache in 24.165381812s
6:26:10 PM: Starting to prepare the repo for build
6:26:10 PM: Preparing Git Reference refs/heads/preview
6:26:12 PM: Parsing package.json dependencies
6:26:13 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/dist' versus '/' in the Netlify UI
6:26:13 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'api/dist/functions' versus '' in the Netlify UI
6:26:13 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'yarn rw deploy netlify' versus '' in the Netlify UI
6:26:13 PM: Starting build script
6:26:13 PM: Installing dependencies
6:26:13 PM: Python version set to 2.7
6:26:14 PM: Started restoring cached node version
6:26:18 PM: Finished restoring cached node version
6:26:18 PM: Attempting node version 'lts/*' from .nvmrc
6:26:18 PM: v14.16.0 is already installed.
6:26:19 PM: Now using node v14.16.0 (npm v6.14.11)
6:26:19 PM: Started restoring cached build plugins
6:26:19 PM: Finished restoring cached build plugins
6:26:19 PM: Attempting ruby version 2.7.1, read from environment
6:26:21 PM: Using ruby version 2.7.1
6:26:21 PM: Using PHP version 5.6
6:26:21 PM: Started restoring cached yarn cache
6:26:21 PM: Finished restoring cached yarn cache
6:26:22 PM: Started restoring cached node modules
6:26:22 PM: Finished restoring cached node modules
6:26:22 PM: Installing NPM modules using Yarn version 1.22.4
6:26:22 PM: yarn install v1.22.4
6:26:23 PM: [1/5] Validating package.json...
6:26:23 PM: [2/5] Resolving packages...
6:26:23 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
6:26:23 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
6:26:23 PM: warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3"
6:26:23 PM: warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3"
6:26:23 PM: warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3"
6:26:24 PM: [3/5] Fetching packages...
6:27:42 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
6:27:42 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
6:27:42 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
6:27:42 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
6:27:42 PM: [4/5] Linking dependencies...
6:27:42 PM: warning "@redwoodjs/core > @redwoodjs/testing > @redwoodjs/web > react-hot-toast > goober@2.0.33" has unmet peer dependency "csstype@^2.6.2".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router@1.3.4" has incorrect peer dependency "react@15.x || 16.x || 16.4.0-alpha.0911da3".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router@1.3.4" has incorrect peer dependency "react-dom@15.x || 16.x || 16.4.0-alpha.0911da3".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-helmet-async@1.0.7" has incorrect peer dependency "react@^16.6.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-helmet-async@1.0.7" has incorrect peer dependency "react-dom@^16.6.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-sizeme@2.6.12" has incorrect peer dependency "react@^0.14.0 || ^15.0.0-0 || ^16.0.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > react-sizeme@2.6.12" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0-0 || ^16.0.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/addons > @storybook/api > @reach/router > create-react-context@0.3.0" has incorrect peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-popper-tooltip@2.11.1" has incorrect peer dependency "react@^16.6.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-popper-tooltip@2.11.1" has incorrect peer dependency "react-dom@^16.6.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > react-textarea-autosize@7.1.2" has incorrect peer dependency "react@>=0.14.0 <17.0.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > simplebar-react@1.2.3" has incorrect peer dependency "react@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
6:27:42 PM: warning "@redwoodjs/core > @storybook/react > @storybook/core > @storybook/ui > @storybook/components > simplebar-react@1.2.3" has incorrect peer dependency "react-dom@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > @date-io/date-fns@1.3.13" has unmet peer dependency "date-fns@^2.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > @material-ui/pickers@3.2.10" has unmet peer dependency "@date-io/core@^1.3.6".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > @material-ui/pickers@3.2.10" has incorrect peer dependency "react@^16.8.4".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > @material-ui/pickers@3.2.10" has incorrect peer dependency "react-dom@^16.8.4".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > dexie-react-hooks@1.0.6" has unmet peer dependency "@types/react@>=16".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > sass-loader@10.1.1" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > postcss-loader@4.0.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > postcss-loader@4.0.2" has unmet peer dependency "postcss@^7.0.0 || ^8.0.1".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/addons@^5.0.0 || ^6.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/components@^5.0.0 || ^6.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs@5.4.5" has unmet peer dependency "@storybook/theming@^5.0.0 || ^6.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs > react-pdf@4.2.0" has incorrect peer dependency "react@^16.3.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs > react-pdf@4.2.0" has incorrect peer dependency "react-dom@^16.3.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > api > firebase-admin > @firebase/database > @firebase/auth-interop-types@0.1.5" has unmet peer dependency "@firebase/app-types@0.x".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs > react-pdf > pdfjs-dist@2.1.266" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > api > @redwoodjs/api > graphql-tools > @graphql-tools/links > apollo-upload-client@14.1.2" has unmet peer dependency "subscriptions-transport-ws@^0.9.0".
6:27:42 PM: warning "workspace-aggregator-dc589504-7bc9-4cff-9164-e2153a2a0a70 > web > storybook-addon-designs > react-pdf > pdfjs-dist > worker-loader@2.0.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
6:28:34 PM: [5/5] Building fresh packages...
6:28:47 PM: Done in 144.24s.
6:28:47 PM: NPM modules installed using Yarn
6:28:47 PM: Started restoring cached go cache
6:28:47 PM: Finished restoring cached go cache
6:28:47 PM: go version go1.14.4 linux/amd64
6:28:47 PM: go version go1.14.4 linux/amd64
6:28:47 PM: Installing missing commands
6:28:47 PM: Verify run directory
6:28:50 PM: ​
6:28:50 PM: ────────────────────────────────────────────────────────────────
6:28:50 PM:   Netlify Build                                                 
6:28:50 PM: ────────────────────────────────────────────────────────────────
6:28:50 PM: ​
6:28:50 PM: ❯ Version
6:28:50 PM:   @netlify/build 9.13.0
6:28:50 PM: ​
6:28:50 PM: ❯ Flags
6:28:50 PM:   apiHost: api.netlify.com
6:28:50 PM:   cacheDir: /opt/build/cache
6:28:50 PM:   deployId: 605b761631e64800077add61
6:28:50 PM:   mode: buildbot
6:28:50 PM:   testOpts:
6:28:50 PM:     silentLingeringProcesses: ''
6:28:50 PM: ​
6:28:50 PM: ❯ Current directory
6:28:50 PM:   /opt/build/repo
6:28:50 PM: ​
6:28:50 PM: ❯ Config file
6:28:50 PM:   /opt/build/repo/netlify.toml
6:28:50 PM: ​
6:28:50 PM: ❯ Context
6:28:50 PM:   production
6:28:50 PM: ​
6:28:50 PM: ────────────────────────────────────────────────────────────────
6:28:50 PM:   1. build.command from netlify.toml                            
6:28:50 PM: ────────────────────────────────────────────────────────────────
6:28:50 PM: ​
6:28:50 PM: $ yarn rw deploy netlify
6:28:50 PM: yarn run v1.22.4
6:28:50 PM: $ /opt/build/repo/node_modules/.bin/rw deploy netlify
6:28:53 PM: $ /opt/build/repo/node_modules/.bin/rw build
6:28:57 PM: Generating the Prisma client... [started]
6:29:03 PM: Generating the Prisma client... [completed]
6:29:03 PM: [17:29:03] Cleaning "web"... (./web/dist/) [started]
6:29:04 PM: [17:29:04] Cleaning "web"... (./web/dist/) [completed]
6:29:04 PM: [17:29:04] Building "api"... [started]
6:29:09 PM: [17:29:09] Building "api"... [completed]
6:29:09 PM: [17:29:09] Building "web"... [started]
6:30:28 PM: [17:30:28] Building "web"... [completed]
6:30:28 PM: [17:30:28] Prerendering "web"... [started]
6:30:28 PM: [17:30:28] Prerendering "web"... [skipped]
6:30:28 PM: [17:30:28] → You have not marked any routes as `prerender` in `Routes.{js,tsx}`
6:30:28 PM: $ /opt/build/repo/node_modules/.bin/rw prisma migrate deploy
6:30:31 PM: 
6:30:31 PM: Running Prisma CLI:
6:30:31 PM: yarn prisma migrate deploy --preview-feature --schema "/opt/build/repo/api/db/schema.prisma"
6:30:33 PM: Prisma schema loaded from db/schema.prisma
6:30:33 PM: Datasource "DS": PostgreSQL database "dfr5oiju25f2go", schema "public" at "ec2-176-34-222-188.eu-west-1.compute.amazonaws.com:5432"
6:30:35 PM: 8 migrations found in prisma/migrations
6:30:43 PM: The following migrations have been applied:
6:30:43 PM: migrations/
6:30:43 PM:   └─ 20210315103844_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210316122856_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210317102903_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210318181412_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210322164002_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210323111754_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210323112401_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM:   └─ 20210324150742_/
6:30:43 PM:     └─ migration.sql
6:30:43 PM: All migrations have been successfully applied.
6:30:45 PM: $ /opt/build/repo/node_modules/.bin/rw dataMigrate up
6:30:51 PM: 
6:30:51 PM: No data migrations run, already up-to-date.
6:30:51 PM: 
6:30:51 PM: Done in 120.71s.
6:30:51 PM: ​
6:30:51 PM: (build.command completed in 2m 1s)
6:30:51 PM: ​
6:30:51 PM: ────────────────────────────────────────────────────────────────
6:30:51 PM:   2. Functions bundling                                         
6:30:51 PM: ────────────────────────────────────────────────────────────────
6:30:51 PM: ​
6:30:51 PM: Packaging Functions from api/dist/functions directory:
6:30:51 PM:  - graphql.js
6:30:51 PM: ​
6:31:44 PM: ​
6:31:44 PM: (Functions bundling completed in 53.1s)
6:31:44 PM: ​
6:31:44 PM: ────────────────────────────────────────────────────────────────
6:31:44 PM:   3. Deploy site                                                
6:31:44 PM: ────────────────────────────────────────────────────────────────
6:31:44 PM: ​
6:31:44 PM: Starting to deploy site from 'web/dist'
6:31:44 PM: Creating deploy tree 
6:31:44 PM: Creating deploy upload records
6:31:45 PM: 5 new files to upload
6:31:45 PM: 0 new functions to upload
6:31:46 PM: Site deploy was successfully initiated
6:31:46 PM: ​
6:31:46 PM: (Deploy site completed in 1.7s)
6:31:46 PM: ​
6:31:46 PM: ────────────────────────────────────────────────────────────────
6:31:46 PM:   Netlify Build Complete                                        
6:31:46 PM: ────────────────────────────────────────────────────────────────
6:31:46 PM: ​
6:31:46 PM: (Netlify Build completed in 2m 56s)
6:31:46 PM: Starting post processing
6:31:46 PM: Post processing - HTML
6:31:46 PM: Caching artifacts
6:31:46 PM: Started saving node modules
6:31:46 PM: Finished saving node modules
6:31:46 PM: Started saving build plugins
6:31:46 PM: Finished saving build plugins
6:31:46 PM: Started saving yarn cache
6:31:46 PM: Post processing - header rules
6:31:46 PM: Finished saving yarn cache
6:31:46 PM: Started saving pip cache
6:31:46 PM: Post processing - redirect rules
6:31:46 PM: Finished saving pip cache
6:31:46 PM: Started saving emacs cask dependencies
6:31:46 PM: Post processing done
6:31:46 PM: Finished saving emacs cask dependencies
6:31:46 PM: Started saving maven dependencies
6:31:46 PM: Finished saving maven dependencies
6:31:46 PM: Started saving boot dependencies
6:31:46 PM: Finished saving boot dependencies
6:31:46 PM: Started saving rust rustup cache
6:31:46 PM: Finished saving rust rustup cache
6:31:46 PM: Started saving go dependencies
6:31:46 PM: Finished saving go dependencies
6:31:46 PM: Build script success
6:31:46 PM: Site is live ✨
6:33:06 PM: Finished processing build request in 7m20.443028492s

It looks like something is not transpiling correctly, could you look into your “dist” folder and and search for files that contain the import syntax?

Just checked, locally, no results.

I then did a netlify build for good measure, checked the archive, nothing pops up in there either :-\.

And just to make 100% sure this is working locally? I wonder if there’s a .mjs file in a node_module somewhere, and this is being attempted instead of a cjs export.

I think Netlify is running on NodeJS 12.

A 100% !

Good catch on nodejs 12, I’ll switch locally to see what happens.

About the .mjs it would make sense, however so far I don’t believe I have installed packages on this project I hadn’t installed on my previous project, which works on preprod.

I’ll check & report :rocket:

But if that’s the case, v0.27.0 and above will not work on netlify, right?

Update:
Checked the log, actually it says:

8:41:36 AM: Now using node v14.16.0 (npm v6.14.11)

I installed it locally and gave it a spin, it still works like a charm. I’m considering local hosting the app for ever x).

1 Like

Interesting, are you sure that’s runtime and not build-time on Netlify?

We transpile the api source down to NodeJS v12 when we build it.

Hmmm… I wonder if it has something to do with NODE_ENV=production, unfortunately we set that explicitly when developing the api-side so it’s difficult to test.

I’d say runtime and not build time because:

I could be mistaken on these, it definitely isn’t my strong suit.

That’s really bizarre, if such was the case shouldn’t I also have it in RW app with versions from v0.23 and above, hosted on Netlify as well?

I reached to their forums 2 days ago, no answer at all :-\

I tried deploying on Vercel, this is what I get:

Error: Minified React error #130

Even worst :-/.

Found it

I had some imports which included the workspace api:

import {createAccount} from 'api/src/services/accounts/accounts'

They were working on local and I had no warning of any kind, i think they might have been a misconfiguration of my IDE at some point, but I have a couple more points to check.

Removing the workspace made the import work again.

import {createAccount} from 'src/services/accounts/accounts'

Not sure how exactly it can go from there to the error message in the original post :-\

2 Likes