Hey y’all!
I have been working through the Build Plugins docs and trying to get my local build plugin to build correctly.
In the plugin, I have a dependency on an npm module (axios). When I “npm install” directly, it will install the plugin, and everything runs just fine. If I remove the node_modules directory, and run “netlify build” to simulate a cloud build, it doesn’t seem to run npm install and install the necessary dependencies. Thus I get the below.
My versions:
netlify-cli/6.10.4 darwin-x64 node-v12.19.1
Should I be including a node_modules with my local build plugin?
Thanks, y’all!
Andy
────────────────────────────────────────────────────────────────
Netlify Build
────────────────────────────────────────────────────────────────
❯ Version
@netlify/build 18.13.10
❯ Flags
dry: false
offline: false
❯ Current directory
/Users/andy/src/github.com/waviisoft/my-poc
❯ Config file
/Users/andy/src/github.com/waviisoft/my-poc/netlify.toml
❯ Context
production
❯ Loading plugins
- /netlify-plugins/my-plugin@0.1.0 from netlify.toml
────────────────────────────────────────────────────────────────────
Plugin “/netlify-plugins/my-plugin” internal error
────────────────────────────────────────────────────────────────────
Error message
Error: Could not import plugin:
Cannot find module ‘axios’
Require stack:
- /Users/andy/src/github.com/waviisoft/my-poc/netlify-plugins/my-plugin/src/index.js
- /Users/andy/.nvm/versions/node/v12.19.1/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/logic.js
- /Users/andy/.nvm/versions/node/v12.19.1/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/load.js
- /Users/andy/.nvm/versions/node/v12.19.1/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/main.js
Plugin details
Package: /netlify-plugins/my-plugin
Version: 0.1.0
Error location
While loading “/netlify-plugins/my-plugin” from netlify.toml
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/Users/andy/src/github.com/waviisoft/my-poc/netlify-plugins/my-plugin/src/index.js:11:15)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
Error properties
{ code: ‘MODULE_NOT_FOUND’ }
Resolved config
build:
publish: /Users/andy/src/github.com/waviisoft/my-poc
publishOrigin: default
plugins:
- inputs: {}
origin: config
package: /netlify-plugins/my-plugin