I’m running a fairly standard Eleventy site but for some reason it’s started failing to build on Netlify since I’ve started using the markdown-it and markdown-it-attrs packages. It builds fine locally.
They are listed in package.json:
"dependencies": {
"markdown-it": "^13.0.1",
"markdown-it-attrs": "^4.1.4",
"sass": "^1.53.0"
}
But when running my build command, I get the error:
6:50:27 PM: [11ty] 1. Error in your Eleventy config file '/opt/build/repo/.eleventy.js'. You may need to run `npm install`. (via EleventyConfigError)
6:50:27 PM: [11ty] 2. Cannot find module 'markdown-it'
I’ve tried tweaking my eleventy.js config and my build script and the only thing that seems to work is by prepending my build command with npm install.
I thought Netlify automatically ran npm install so I’m unsure why I need to do this. Anyone have any insight?
My build settings:
- Base directory:
_site - Build command:
npm run build - Publish directory:
Not set - Builds:
Active
My build script:
"build": "npx sass style:_site/style && npx @11ty/eleventy"
Build log:
6:07:20 PM: Build ready to start
6:07:22 PM: build-image version: 1ac2360cf8aee6cb2695dd2682b312fefc908a7f (xenial)
6:07:22 PM: build-image tag: v3.15.0
6:07:22 PM: buildbot version: fe6512288e75c8fa5aadaebb51ed1f96e9314fd4
6:07:22 PM: Fetching cached dependencies
6:07:22 PM: Starting to download cache of 73.3MB
6:07:23 PM: Finished downloading cache in 785.515846ms
6:07:23 PM: Starting to extract cache
6:07:23 PM: Finished extracting cache in 464.754139ms
6:07:23 PM: Finished fetching cache in 1.32089547s
6:07:23 PM: Starting to prepare the repo for build
6:07:24 PM: Preparing Git Reference refs/heads/main
6:07:24 PM: Parsing package.json dependencies
6:07:25 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: '_site' versus '' in the Netlify UI
6:07:25 PM: Starting build script
6:07:25 PM: Installing dependencies
6:07:25 PM: Python version set to 2.7
6:07:25 PM: Started restoring cached node version
6:07:26 PM: Finished restoring cached node version
6:07:27 PM: v12.18.0 is already installed.
6:07:27 PM: Now using node v12.18.0 (npm v6.14.4)
6:07:27 PM: Started restoring cached build plugins
6:07:27 PM: Finished restoring cached build plugins
6:07:27 PM: Attempting ruby version 2.7.2, read from environment
6:07:28 PM: Using ruby version 2.7.2
6:07:28 PM: Using PHP version 5.6
6:07:28 PM: Started restoring cached go cache
6:07:28 PM: Finished restoring cached go cache
6:07:28 PM: go version go1.14.4 linux/amd64
6:07:28 PM: go version go1.14.4 linux/amd64
6:07:28 PM: Installing missing commands
6:07:28 PM: Verify run directory
6:07:29 PM:
6:07:29 PM: ────────────────────────────────────────────────────────────────
6:07:29 PM: Netlify Build
6:07:29 PM: ────────────────────────────────────────────────────────────────
6:07:29 PM:
6:07:29 PM: ❯ Version
6:07:29 PM: @netlify/build 27.9.1
6:07:29 PM:
6:07:29 PM: ❯ Flags
6:07:29 PM: baseRelDir: true
6:07:29 PM: buildId: 62f142c81d69b800082c8506
6:07:29 PM: deployId: 62f142c81d69b800082c8508
6:07:29 PM: systemLogFile: 3
6:07:29 PM:
6:07:29 PM: ❯ Current directory
6:07:29 PM: /opt/build/repo/_site
6:07:29 PM:
6:07:29 PM: ❯ Config file
6:07:29 PM: No config file was defined: using default values.
6:07:29 PM:
6:07:29 PM: ❯ Context
6:07:29 PM: production
6:07:29 PM:
6:07:29 PM: ────────────────────────────────────────────────────────────────
6:07:29 PM: 1. Build command from Netlify app
6:07:29 PM: ────────────────────────────────────────────────────────────────
6:07:29 PM:
6:07:29 PM: $ npm run build
6:07:29 PM: > @ build /opt/build/repo
6:07:29 PM: > npx sass style:_site/style && npx @11ty/eleventy
6:07:31 PM: npx: installed 17 in 1.633s
6:07:46 PM: npx: installed 328 in 15.064s
6:07:47 PM: [11ty] Eleventy CLI Fatal Error: (more in DEBUG output)
6:07:47 PM: [11ty] 1. Error in your Eleventy config file '/opt/build/repo/.eleventy.js'. You may need to run `npm install`. (via EleventyConfigError)
6:07:47 PM: [11ty] 2. Cannot find module 'markdown-it'
6:07:47 PM: [11ty] Require stack:
6:07:47 PM: [11ty] - /opt/build/repo/.eleventy.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateConfig.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateRender.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateData.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/Eleventy.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/cmd.js (via Error)
6:07:47 PM: [11ty]
6:07:47 PM: [11ty] Original error stack trace: Error: Cannot find module 'markdown-it'
6:07:47 PM: [11ty] Require stack:
6:07:47 PM: [11ty] - /opt/build/repo/.eleventy.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateConfig.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateRender.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/TemplateData.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/src/Eleventy.js
6:07:47 PM: [11ty] - /opt/buildhome/.npm/_npx/1547/lib/node_modules/@11ty/eleventy/cmd.js
6:07:47 PM: [11ty] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
6:07:47 PM: [11ty] at Function.Module._load (internal/modules/cjs/loader.js:842:27)
6:07:47 PM: [11ty] at Module.require (internal/modules/cjs/loader.js:1026:19)
6:07:47 PM: [11ty] at require (internal/modules/cjs/helpers.js:72:18)
6:07:47 PM: [11ty] at Object.<anonymous> (/opt/build/repo/.eleventy.js:1:20)
6:07:47 PM: [11ty] at Module._compile (internal/modules/cjs/loader.js:1138:30)
6:07:47 PM: [11ty] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
6:07:47 PM: [11ty] at Module.load (internal/modules/cjs/loader.js:986:32)
6:07:47 PM: [11ty] at Function.Module._load (internal/modules/cjs/loader.js:879:14)
6:07:47 PM: [11ty] at Module.require (internal/modules/cjs/loader.js:1026:19)
6:07:47 PM: npm ERR! code ELIFECYCLE
6:07:47 PM: npm ERR! errno 1
6:07:47 PM: npm ERR! @ build: `npx sass style:_site/style && npx @11ty/eleventy`
6:07:47 PM: npm ERR! Exit status 1
6:07:47 PM: npm ERR!
6:07:47 PM: npm ERR! Failed at the @ build script.
6:07:47 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
6:07:47 PM: npm WARN Local package.json exists, but node_modules missing, did you mean to install?
6:07:47 PM: npm ERR! A complete log of this run can be found in:
6:07:47 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-08-08T17_07_47_595Z-debug.log
6:07:47 PM:
6:07:47 PM: ────────────────────────────────────────────────────────────────
6:07:47 PM: "build.command" failed
6:07:47 PM: ────────────────────────────────────────────────────────────────
6:07:47 PM:
6:07:47 PM: Error message
6:07:47 PM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
6:07:47 PM:
6:07:47 PM: Error location
6:07:47 PM: In Build command from Netlify app:
6:07:47 PM: npm run build
6:07:47 PM:
6:07:47 PM: Resolved config
6:07:47 PM: build:
6:07:47 PM: base: /opt/build/repo/_site
6:07:47 PM: command: npm run build
6:07:47 PM: commandOrigin: ui
6:07:47 PM: publish: /opt/build/repo/_site
6:07:47 PM: publishOrigin: default
6:07:48 PM: Caching artifacts
6:07:48 PM: Started saving build plugins
6:07:48 PM: Finished saving build plugins
6:07:48 PM: Started saving pip cache
6:07:48 PM: Finished saving pip cache
6:07:48 PM: Started saving emacs cask dependencies
6:07:48 PM: Finished saving emacs cask dependencies
6:07:48 PM: Started saving maven dependencies
6:07:48 PM: Finished saving maven dependencies
6:07:48 PM: Started saving boot dependencies
6:07:48 PM: Finished saving boot dependencies
6:07:48 PM: Started saving rust rustup cache
6:07:48 PM: Finished saving rust rustup cache
6:07:48 PM: Started saving go dependencies
6:07:48 PM: Finished saving go dependencies
6:07:48 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:07:48 PM: Creating deploy upload records
6:07:48 PM: Failing build: Failed to build site
6:07:48 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
6:07:48 PM: Finished processing build request in 26.039673378s