I have a very simple aws code pipeline to build Nuxt for SSR on eleastic beanstalk.
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
pre_build:
commands:
- yarn
build:
commands:
- yarn build --max-old-space-size=2048
artifacts:
base-directory: ./
files:
- '**/*'
cache:
paths:
It fails on Elastic Beanstalk with this error:
web: > nuxt start
web: internal/modules/cjs/loader.js:905
web: throw err;
web: ^
web: Error: Cannot find module '../package.json'
web: Require stack:
web: - /var/app/current/node_modules/.bin/nuxt
web: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
web: at Function.Module._load (internal/modules/cjs/loader.js:746:27)
web: at Module.require (internal/modules/cjs/loader.js:974:19)
web: at require (internal/modules/cjs/helpers.js:93:18)
web: at Object.<anonymous> (/var/app/current/node_modules/.bin/nuxt:5:16)
web: at Module._compile (internal/modules/cjs/loader.js:1085:14)
web: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
web: at Module.load (internal/modules/cjs/loader.js:950:32)
web: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
web: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
web: code: 'MODULE_NOT_FOUND',
web: requireStack: [ '/var/app/current/node_modules/.bin/nuxt' ]
web: }
If I download the application to my local I get the same problem. BUT if I rerun
yarn install
it starts working.
it looks like it is this line of node_modules/.bin/nuxt
const suffix = require('../package.json')
Because it is in the .bin folder there isn't any package.json, not should how this ever works.
So I am trying to figure out how the yarn install is different on aws pipeline vs local. Same yarn versions on pipeline and local 1.22.1
What breaks if you move your Nuxt Application from one server/location to another? I can build it local and upload it to Elastic Beanstalk and that works.
Any suggestions would be a big help.