I'm trying to deploy a NextJs project using Sanity at the backend side, at deployment this error occurs:
[13:36:44.275] Retrieving list of deployment files...
[13:36:44.750] Previous build caches not available
[13:36:44.799] Downloading 72 deployment files...
[13:36:45.460] Running "vercel build"
[13:36:45.926] Vercel CLI 28.10.0
[13:36:46.203] Installing dependencies...
[13:36:46.521] yarn install v1.22.17
[13:36:46.563] [1/4] Resolving packages...
[13:36:47.744] [2/4] Fetching packages...
[13:36:57.604] [3/4] Linking dependencies...
[13:36:57.606] warning " > next-sanity#3.1.9" has incorrect peer dependency "next#^13".
[13:37:07.243] [4/4] Building fresh packages...
[13:37:07.517] success Saved lockfile.
[13:37:07.520] Done in 21.00s.
[13:37:07.555] Detected Next.js version: 12.2.2
[13:37:07.556] Running "yarn run build"
[13:37:07.799] yarn run v1.22.17
[13:37:07.820] $ next build
[13:37:08.210] info - SWC minify release candidate enabled. https://nextjs.link/swcmin
[13:37:08.366] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[13:37:08.366] This information is used to shape Next.js' roadmap and prioritize features.
[13:37:08.366] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[13:37:08.367] https://nextjs.org/telemetry
[13:37:08.367]
[13:37:08.624] info - Linting and checking validity of types...
[13:37:11.901] info - Creating an optimized production build...
[13:37:17.601] info - Compiled successfully
[13:37:17.601] info - Collecting page data...
[13:37:19.578] info - Generating static pages (0/3)
[13:37:19.717] (node:466) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
[13:37:19.718] (Use `node --trace-warnings ...` to show where the warning was created)
[13:37:19.723]
[13:37:19.724] Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
[13:37:19.724] TypeError: fetch failed
[13:37:19.724] at Object.fetch (node:internal/deps/undici/undici:11118:11)
[13:37:19.724] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[13:37:19.724] at async fetchSkils (/vercel/path0/.next/server/pages/index.js:1197:17)
[13:37:19.724] at async getStaticProps (/vercel/path0/.next/server/pages/index.js:1091:20)
[13:37:19.724] at async renderToHTML (/vercel/path0/node_modules/next/dist/server/render.js:451:20)
[13:37:19.724] at async /vercel/path0/node_modules/next/dist/export/worker.js:251:36
[13:37:19.724] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:20)
[13:37:19.725] info - Generating static pages (3/3)
[13:37:19.725]
[13:37:19.725] > Build error occurred
[13:37:19.727] Error: Export encountered errors on following paths:
[13:37:19.727] /
[13:37:19.727] at /vercel/path0/node_modules/next/dist/export/index.js:395:19
[13:37:19.727] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[13:37:19.727] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:20)
[13:37:19.728] at async /vercel/path0/node_modules/next/dist/build/index.js:1094:21
[13:37:19.728] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:20)
[13:37:19.728] at async /vercel/path0/node_modules/next/dist/build/index.js:971:17
[13:37:19.728] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:20)
[13:37:19.728] at async Object.build [as default] (/vercel/path0/node_modules/next/dist/build/index.js:64:29)
[13:37:19.762] error Command failed with exit code 1.
[13:37:19.762] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[13:37:19.779] Error: Command "yarn run build" exited with 1
After reading docs about the issue, I found that, the build cannot fetch data at this level during deployment( but it works fine on development side):
export const getStaticProps:GetStaticProps<Props> = async () => {
const skills: Skill[] = await fetchSkils();
const projects: Project[] = await fetchProjects();
const pageInfo: PageInfo = await fetchPageinfo();
const experiences: Experience[] = await fetchExperience();
return {
props: {
pageInfo,
experiences,
skills,
projects,
},
revalidate:1000,
};
};
I think that the mismatch between dependencies is the reason for it:
warning " > next-sanity#3.1.9" has incorrect peer dependency "next#^13".
So anybody knows what dependencies can work well together??
I currently have a monorepo setup with serverless and it builds alright, when I try a custom deploy script, I get the following error
DEBUG ─ Executing the template's components graph.
error:
Error: Command failed with ENOENT: node_modules/.bin/next build
spawn node_modules/.bin/next ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:470:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn node_modules/.bin/next',
path: 'node_modules/.bin/next',
spawnargs: [ 'build' ],
originalMessage: 'spawn node_modules/.bin/next ENOENT',
shortMessage: 'Command failed with ENOENT: node_modules/.bin/next build\n' +
'spawn node_modules/.bin/next ENOENT',
command: 'node_modules/.bin/next build',
escapedCommand: '"node_modules/.bin/next" build',
exitCode: undefined,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr: '',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
4s › web › Error: Command failed with ENOENT: node_modules/.bin/next build
spawn node_modules/.bin/next ENOENT
I tried to set next.config.js with
const nextConfig = {
experimental: {
externalDir: true,
},
};
export default nextConfig;
Still the error persist.
my deploy script is "deploy": "AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=projec1 yarn components-v1 --debug"
The cloud function was working good before updating it. This is the code where the error occurs now:
return spawn('convert' ,[tempLocalFile, '-thumbnail', `${THUMB_MAX_WIDTH}x${THUMB_MAX_HEIGHT}`, tempLocalThumbFile], {capture: ['stdout', 'stderr']});
Below is the detail of the error:
generateThumbnail Error: {
Error: spawn convert ENOENT at _errnoException
(util.js:1022:11) at Process.ChildProcess._handle.onexit
(internal/child_process.js:190:19) at onErrorNT
(internal/child_process.js:372:16) at _combinedTickCallback
(internal/process/next_tick.js:138:11) at process._tickDomainCallback
(internal/process/next_tick.js:218:9)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn convert',
path: 'convert',
spawnargs: [
'/tmp/images/E32NIXQKgVUxjUGDmPkr_aaaa',
'-thumbnail',
'400x220',
'/tmp/images/thumb_E32NIXQKgVUxjUGDmPkr_aaaa'
]
}
Is I'm doing something wrong or Is this the firebase cloud error?
For local development : brew install imagemagick
I'm following this tutorial on building a React app on top of WordPress, and I'm having trouble starting it.
I modified package.json file a bit and webpack.config.js` and I am getting the following error in my terminal
➜ wp-api git:(development) ✗ npm start
> wp-api#1.0.0 start /Users/myuser/Projects/wp-api
> webpack-dev-server --open
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolve has an unknown property 'modulesDirectories'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
- configuration.resolve.extensions[0] should not be empty.
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/Cellar/node/7.10.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.10.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wp-api#1.0.0 start: `webpack-dev-server --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wp-api#1.0.0 start script 'webpack-dev-server --open'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the wp-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --open
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs wp-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls wp-api
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/myuser/.npm/_logs/2017-05-15T07_40_36_249Z-debug.log
The log file is
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.10.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'start' ]
2 info using npm#4.2.0
3 info using node#v7.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle wp-api#1.0.0~prestart: wp-api#1.0.0
6 silly lifecycle wp-api#1.0.0~prestart: no script for prestart, continuing
7 info lifecycle wp-api#1.0.0~start: wp-api#1.0.0
8 verbose lifecycle wp-api#1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle wp-api#1.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/myuser/Projects/wp-api/node_modules/.bin:/Users/myuser/.rbenv/shims:/Users/myuser/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
10 verbose lifecycle wp-api#1.0.0~start: CWD: /Users/myuser/Projects/wp-api
11 silly lifecycle wp-api#1.0.0~start: Args: [ '-c', 'webpack-dev-server --open' ]
12 silly lifecycle wp-api#1.0.0~start: Returned: code: 1 signal: null
13 info lifecycle wp-api#1.0.0~start: Failed to exec start script
14 verbose stack Error: wp-api#1.0.0 start: `webpack-dev-server --open`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid wp-api#1.0.0
16 verbose cwd /Users/myuser/Projects/wp-api
17 error Darwin 16.5.0
18 error argv "/usr/local/Cellar/node/7.10.0/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.10.0
20 error npm v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error wp-api#1.0.0 start: `webpack-dev-server --open`
23 error Exit status 1
24 error Failed at the wp-api#1.0.0 start script 'webpack-dev-server --open'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the wp-api package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error webpack-dev-server --open
24 error You can get information on how to open an issue for this project with:
24 error npm bugs wp-api
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls wp-api
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
The package.json and webpack.config.js are:
{
"name": "wp-api",
"version": "1.0.0",
"description": "React based WordPress app",
"main": "index.js",
"dependencies": {
"alt": "^0.18.6",
"axios": "^0.15.3",
"extract-text-webpack-plugin": "^2.1.0",
"lodash": "^4.17.4",
"node-sass": "^4.5.2",
"prop-types": "^15.5.8",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router": "^3.0.1",
"sass-loader": "^6.0.3"
},
"devDependencies": {
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-preset-env": "^1.4.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.0",
"firebase-tools": "^3.6.1",
"html-webpack-plugin": "^2.28.0",
"react-hot-loader": "^1.3.1",
"style-loader": "^0.16.1",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.2"
},
"scripts": {
"start": "webpack-dev-server --open",
"test": "echo \"Error: no test specified\" && exit 1"
},
"babel": {
"presets": [
"env",
"react"
]
},
"author": "dingo-d",
"license": "GPL"
}
and
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const outputCss = 'styles/[name].css';
var config = {
devtool: 'inline-source-map', // This will show line numbers where errors are accured in the terminal
devServer: {
historyApiFallback: true, // This will make the server understand "/some-link" routs instead of "/#/some-link"
},
entry: [
'webpack-dev-server/client?http://127.0.0.1:8080/', // Specify the local server port
'webpack/hot/only-dev-server', // Enable hot reloading
'./src/index' // This is where Webpack will be looking for the entry index.js file
],
output: {
path: path.join(__dirname, 'public'), // This is used to specify folder for producion bundle. Will not be used here, but it's a good practice to have it
filename: 'bundle.js' // Filename for production bundle
// publicPath: '/'
},
resolve: {
modulesDirectories: ['node_modules', 'src'], // Folders where Webpack is going to look for files to bundle together
extensions: ['', '.js'] // Extensions that Webpack is going to expect
},
module: {
// Loaders allow you to preprocess files as you require() or “load” them. Loaders are kind of like “tasks” in other build tools, and provide a powerful way to handle frontend build steps.
loaders: [
{
test: /\.jsx?$/, // Here we're going to use JS for react components but including JSX in case this extension is prefered
exclude: /node_modules/, // Speaks for itself
loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015'] // Modules that help with hot reloading and ES6 transcription
}
],
rules: [
{ test: /\.(js)$/, use: 'babel-loader' },
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
})
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(), // Hot reloading
new webpack.NoErrorsPlugin(), // Webpack will let you know if there are any errors
new HtmlWebpackPlugin({
template: 'index.html'
}),
]
}
module.exports = config;
I haven't done much projects with webpack, so my knowledge in this aspect is very limited.
What am I doing wrong? I tried deleting the node_modules folder and running npm install again, but that didn't work.
Solution to the 1st problem:
npm uninstall webpack --save-dev
npm install webpack#2.1.0-beta.22 --save-dev
Solution to the
configuration.resolve.extensions[0] should not be empty. :
Remove '' from the array
resolve: {
modulesDirectories: ['node_modules', 'src'], // Folders where Webpack is going to look for files to bundle together
extensions: ['.js'] // Extensions that Webpack is going to expect
},
Or replace it with '*'
resolve: {
modulesDirectories: ['node_modules', 'src'], // Folders where Webpack is going to look for files to bundle together
extensions: ['*','.js'] // Extensions that Webpack is going to expect
},
1.I use command
pm2 start pm2.json
my pm2.json is
{
"apps": [{
"name": "test_pm2",
"script": "www/app.js",
"cwd": "/var/www/test_pm2",
"exec_mode": "cluster",
"instances": 0,
"max_memory_restart": "1G",
"autorestart": true,
"node_args": [],
"args": [],
"env": {
}
}]
}
2.then i use command
pm2 reload all
and pm2 stop all process,but can't relaod my project,The command line is always waiting.
To visit my project throgh browser,the Nginx 502 error showed.
So i have to use commond pm2 start pm2.json to start.
My environment:
pm2 v2.4.0; node v6.9.5; npm v3.10.10
I hope someone can answer the confusion, thanks!
Just looking over your file these may be the problems. (not sure)
"apps": [{
"name": "test_pm2",
"script": "www/app.js",
"cwd": "/var/www/test_pm2",
"exec_mode": "cluster",
"instances": 0,
"max_memory_restart": "1G",
"autorestart": true,
"node_args": [],
"args": [],
"env": {
}
script: --> are you sure this is the correct path?? Usually it would read:
"./app.js",
cwd: ---> maybe it is var\html\www ???
If all else fails try instances: 'max'
and get rid of the max_memory_restart
Also make sure you are running the app.js by way of the pm2.json file (kind of obvious).
To see where the problem is coming from do it step by step. Some of the commands in your pm2.json file may be problematic.
Hope this helps.
answering my own question !
The pm2.log is:
===============================================================================
2017-03-31 13:23:12: --- PM2 global error caught ---------------------------------------------------
2017-03-31 13:23:12: Time : Fri Mar 31 2017 13:23:12 GMT+0800 (CST)
2017-03-31 13:23:12: Cannot read property 'forEach' of null
2017-03-31 13:23:12: TypeError: Cannot read property 'forEach' of null
at ChildProcess.onClose (/usr/lib/node_modules/pm2/lib/TreeKill.js:104:26)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2017-03-31 13:23:12: ===============================================================================
2017-03-31 13:23:12: [PM2][%s] Resurrecting PM2
2017-03-31 13:23:12: Stopping app:tadx_sys id:_old_1
/usr/lib/node_modules/pm2/lib/TreeKill.js:104
allData.match(/\d+/g).forEach(function (pid) {
^
TypeError: Cannot read property 'forEach' of null
at ChildProcess.onClose (/usr/lib/node_modules/pm2/lib/TreeKill.js:104:26)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)
module.js:471
throw err;
^
Error: Cannot find module '/var/www/tadx.borui-ad.com/undefined'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
I have found a solution for the issue in PM2 official GitHub page Go to issue url
Upgrade to PM2 greater than v2.4.0