Closed tgoldenberg closed 7 years ago
Here is the repo that may be causing it - babel-root-import
and the package.json
:
{
"name": "commandiv-next",
"version": "1.0.0",
"description": "Commandiv Marketing website",
"scripts": {
"test": "jest __tests__/*",
"build": "next build",
"start": "NODE_ENV=production node server/ -p $PORT",
"dev": "node server/index.js",
"postinstall": "heroku-nextjs-build"
},
"author": "tgoldenberg",
"dependencies": {
"@mars/heroku-nextjs-build": "^1.1.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-regenerator": "^6.22.0",
"babel-plugin-wrap-in-js": "^1.1.1",
"babel-polyfill": "^6.22.0",
"babel-preset-airbnb": "^2.2.3",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-register": "^6.22.0",
"babel-root-import": "^4.1.5",
"body-parser": "^1.16.0",
"code-point-at": "^1.1.0",
"crypto": "^0.0.3",
"dotenv": "^4.0.0",
"express": "^4.14.1",
"fs": "^0.0.1-security",
"http": "^0.0.0",
"https": "^1.0.0",
"lodash": "^4.17.4",
"mailchimp-api-v3": "^1.7.0",
"mandrill-api": "^1.0.45",
"material-ui": "^0.16.7",
"mongoose": "^4.8.1",
"morgan": "^1.8.0",
"next": "beta",
"node-sass": "latest",
"raw-loader": "^0.5.1",
"react-addons-css-transition-group": "^15.4.2",
"react-addons-pure-render-mixin": "^15.4.2",
"react-addons-transition-group": "^15.4.2",
"react-ga": "^2.1.2",
"react-redux": "^5.0.2",
"react-social-icons": "^2.5.1",
"react-tap-event-plugin": "^2.0.1",
"react-test-renderer": "^15.4.2",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0",
"request-promise": "^4.1.1",
"sass-loader": "^4.1.1",
"webpack": "^1.14.0"
},
"engines": {
"node": "6.9.x"
},
"cacheDirectories": [
"nextjs/node_modules"
],
"devDependencies": {
"babel": "^6.5.2",
"babel-eslint": "^7.1.1",
"babel-jest": "^18.0.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-regenerator": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-preset-airbnb": "^2.2.3",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-root-import": "^4.1.5",
"enzyme": "^2.7.1",
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.9.0",
"flow-bin": "^0.38.0",
"jest": "^18.1.0",
"jest-cli": "^18.1.0",
"react-addons-test-utils": "^15.4.2"
}
}
It also does this, if I remove code-point-at
. Really strange behavior, but works fine locally...
Counting objects: 158, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (155/155), done.
Writing objects: 100% (158/158), 56.50 KiB | 0 bytes/s, done.
Total 158 (delta 92), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.9.x
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 6.9.x via semver.io...
remote: Downloading and installing node 6.9.5...
remote: Using default npm version: 3.10.10
remote: Resolving yarn version (latest) via semver.io...
remote: Downloading and installing yarn (0.19.1)...
remote: Installed yarn 0.19.1
remote:
remote: -----> Restoring cache
remote: Loading 1 from cacheDirectories (package.json):
remote: - nextjs/node_modules
remote:
remote: -----> Building dependencies
remote: Installing node modules (yarn.lock)
remote: yarn install v0.19.1
remote: warning commandiv-next@1.0.0: No license field
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: warning fsevents@1.0.17: The platform "linux" is incompatible with this module.
remote: info "fsevents@1.0.17" is an optional dependency and failed compatibility check. Excluding it from installation.
remote: [3/4] Linking dependencies...
remote: warning "material-ui@0.16.7" has unmet peer dependency "react@^15.0.0".
remote: warning "material-ui@0.16.7" has unmet peer dependency "react-dom@^15.0.0".
remote: warning "react-addons-css-transition-group@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: warning "react-addons-pure-render-mixin@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: warning "react-addons-transition-group@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: warning "react-ga@2.1.2" has unmet peer dependency "react@>= 0.14.0".
remote: warning "react-redux@5.0.2" has unmet peer dependency "react@^0.14.0 || ^15.0.0-0".
remote: warning "react-social-icons@2.5.1" has unmet peer dependency "react@0.13.x || 0.14.x || 15.x.x".
remote: warning "react-tap-event-plugin@2.0.1" has unmet peer dependency "react@^15.4.0-0".
remote: warning "react-tap-event-plugin@2.0.1" has unmet peer dependency "react-dom@^15.4.0-0".
remote: warning "react-test-renderer@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: warning "request-promise@4.1.1" has unmet peer dependency "request@^2.34".
remote: warning "enzyme@2.7.1" has unmet peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || 15.x".
remote: warning "eslint-config-airbnb@14.0.0" has incorrect peer dependency "eslint-plugin-jsx-a11y@^3.0.2".
remote: warning "react-addons-test-utils@15.4.2" has unmet peer dependency "react-dom@^15.4.2".
remote: warning "react-addons-create-fragment@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: warning "react-event-listener@0.4.1" has unmet peer dependency "react@^0.14.0 || ^15.0.0".
remote: warning "recompose@0.21.2" has unmet peer dependency "react@^0.14.0 || ^15.0.0".
remote: warning "glob-promise@3.1.0" has unmet peer dependency "glob@*".
remote: warning "request-promise-core@1.1.1" has unmet peer dependency "request@^2.34".
remote: warning "react-addons-shallow-compare@15.4.2" has unmet peer dependency "react@^15.4.2".
remote: [4/4] Building fresh packages...
remote: error /tmp/build_ef8043c43a4514b067bb67d7caa2afe4/node_modules/node-sass: Command failed.
remote: Exit code: 1
remote: Command: sh
remote: Arguments: -c node scripts/install.js
remote: Directory: /tmp/build_ef8043c43a4514b067bb67d7caa2afe4/node_modules/node-sass
remote: Output:
remote: module.js:471
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module 'code-point-at'
remote: at Function.Module._resolveFilename (module.js:469:15)
remote: at Function.Module._load (module.js:417:25)
remote: at Module.require (module.js:497:17)
remote: at require (internal/module.js:20:19)
remote: at Object.<anonymous> (/tmp/build_ef8043c43a4514b067bb67d7caa2afe4/node_modules/string-width/index.js:3:19)
remote: at Module._compile (module.js:570:32)
remote: at Object.Module._extensions..js (module.js:579:10)
remote: at Module.load (module.js:487:32)
remote: at tryModuleLoad (module.js:446:12)
remote: at Function.Module._load (module.js:438:3)
remote: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - A module may be missing from 'dependencies' in package.json
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
remote:
remote: - This module may be specified in 'devDependencies' instead of 'dependencies'
remote: https://devcenter.heroku.com/articles/nodejs-support#devdependencies
remote:
remote: - This project was built with yarn, which is new and under development. Some projects can still be built more reliably with npm
remote: https://devcenter.heroku.com/articles/nodejs-support#build-behavior
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to commandiv.
remote:
To https://git.heroku.com/commandiv.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/commandiv.git'
Also tried yarn upgrade
Hi @tgoldenberg,
I'm unfamiliar with the babel-root-imports so I can only offer hints as to what may be going wrong here. I see in the description the log lines where things start going wrong:
{ Error: ./~/object.entries/index.js
Module not found: Error: Can't resolve 'define-properties' in '/app/nextjs/node_modules/object.entries'
I'm suspicious of that ~/
which normally expands to the home directory path and then the /app/nextjs/node_modules/object.entries
which is not found.
It seems likely to me that the technique used by those absolute imports does not cooperate with the filesystem workaround required for Next build on Heroku.
If you're determined to use root/absolute imports (understandable!) Then I can offer guidance following a technique I've used with great success. This technique requires configuring the default search path for modules twice:
for the browser in the webpack config (requires Next 2.0) set resolve.modules
to something like
["node_modules", path.resolve(__dirname, "components")]
for the server in package.json
, prefix scripts.start
with a customized Node search path to something like
NODE_PATH=$NODE_PATH:./components next start -p $PORT
Let me know how it goes 🤓
After looking further at Webpack 2 (used by Next), I realize that my technique from Webpack 1 will not work anymore 😞 Webpack 1 had resolve.moduleDirectories
which was analogous to Node's NODE_PATH
variable, but that seems to no longer be the case. I can't say for sure without going through the process trying to solve this myself. I'll update again when/if I have more conclusive info.
@mars, I ended up ditching the attempt at using absolute imports. Also, and this really important to note, is that I could not deploy my app with Yarn. Just could not. Once I commited the yarn.lock
file to my .gitignore
file and removed it from the repo, the deployment went fine. This is a huge point that is very hard to debug. Closing this for now.
Deploying w/ Yarn is supported. This yarn
branch deploys to a Heroku app successfully on Next 1 and 2-beta. I don't think Yarn is the root problem here.
That Babel plugin uses paths.resolve()
which seems suspect next to the build process which moves the build directory twice, filtering .dotfiles
& .dotdirs
along the way.
Confirm the app is using the newest Heroku build adapter 1.1.0 in package.json
or yarn.lock
.
Hopefully it will go smoothly now with npm & relative imports.
Leaving this open. babel-root-import plugin error is a bug. Not compatible until someone makes it otherwise 🌱
Next resolved the underlying static path issue. The Heroku build adapter is no longer required, so if you upgrade to the most recent Next release and remove that heroku-postbuild
script entry from package.json, I believe this issue will be solved.
Update: I have been using the babel-root-import
plugin with success along with this package. The most recent version of Next.js caused a minor bug, but @arunoda was able to provide a workaround. Thanks!
Here is my output,
.babelrc
, andnext.config.js
:.babelrc
next.config.js