问题描述
有人可以帮助我吗?在更新nextjs版本后运行 yarn run dev 命令时,我遇到了这个问题。任何人都可以尽快提供帮助。预先感谢!
当前行为
C:\ Users \ MY HP \ Desktop \项目更新\版本更新> yarn run dev 纱线运行v1.22.4 $下一个 不推荐使用静态目录,而推荐使用public目录。 https://err.sh/vercel/next.js/static-dir-deprecated 准备好-在http:// localhost:3000上启动服务器 信息-使用来自C:\ Users \ MY HP \ Desktop \ project update \ version update.babelrc的外部babel配置 错误-./client/polyfills.js TypeError:C:\ Users \ MY HP \ Desktop \ project update \ version update \ client \ polyfills.js:this.setDynamic不是函数
.balerc
{
"presets": [ "next/babel" ],"plugins": [ "inline-react-svg","transform-object-rest-spread","transform-class-properties","transform-runtime","babel-plugin-static-fs"]
}
next.config.json
const path = require('path');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
var CompressionPlugin = require("compression-webpack-plugin");
var UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var webpack = require('webpack');
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),new UglifyJsPlugin({
uglifyOptions: {
output: {comments: false,beautify: false},compress: true,warnings: false
}
}),new CompressionPlugin({
asset: "[path].gz[query]",algorithm: "gzip",test: /\.js$|\.css$|\.html$/,threshold: 10240,minRatio: 0.8
}),new SWPrecacheWebpackPlugin({
cacheId: 'next-ss',filename: 'sw.js',minify: true,staticFileGlobsIgnorePatterns: [ /\.next\// ],staticFileGlobs: [
'static/**/*',],runtimeCaching: [
{
handler: 'networkFirst',urlPattern: /^https?.*/,},})
],typescript: {
ignoreBuildErrors: true,webpack: function (cfg) {
const originalEntry = cfg.entry
cfg.entry = async () => {
const entries = await originalEntry()
if (
entries['main.js'] &&
!entries['main.js'].includes('./client/polyfills.js')
) {
entries['main.js'].unshift('./client/polyfills.js')
}
return entries
}
return cfg
}
};
package.json
{
"name": "next-Project","version": "0.0.1","description": "Initial port of next-Project front-end application to Next.js","private": true,"license": "MIT","scripts": {
"dev": "next","build": "next build","start": "NODE_ENV=production node server"
},"Now": {
"alias": "next.teo.systems","env": {
"PORT": "8080"
}
},"engines": {
"node": "^13.9.0"
},"dependencies": {
"@babel/plugin-transform-runtime": "^7.11.0","@sentry/node": "^5.4.0","ajv": "^6.12.4","ajv-errors": "^1.0.1","axios": "^0.16.2","axs": "^1.0.6","babel-plugin-transform-class-properties": "^6.24.1","babel-plugin-transform-object-rest-spread": "^6.26.0","babel-plugin-transform-runtime": "^6.23.0","babel-preset-next-react": "^1.1.1","babel-runtime": "^6.26.0","browser-history": "^1.0.1","chart": "^0.1.2","compression-webpack-plugin": "^1.1.11","css": "^2.2.1","express": "^4.16.3","express-force-https": "^1.0.0","express-https-redirect": "^1.0.0","isomorphic-fetch": "^2.2.1","jquery": "^3.2.1","js-cookie": "^2.2.1","lodash": "^4.17.4","lru-cache": "^4.1.2","moment": "^2.21.0","moment-timezone": "^0.5.14","next": "^9.5.2","next-redux-wrapper": "^1.1.3","next-routes": "^1.4.2","nodemailer": "^4.6.3","nodemon": "^1.19.1","pm2": "^3.5.1","promise-polyfill": "8.1.0","prop-types": "^15.6.1","query-string": "^5.1.1","react": "^16.13.1","react-autosuggest": "^9.3.0","react-bootstrap": "^0.31.2","react-bootstrap-dialog": "^0.9.4","react-dom": "^16.13.1","react-dropzone": "^4.2.9","react-ga": "^2.5.6","react-helmet": "^5.2.0","react-icons": "^2.2.5","react-image-gallery": "^0.8.3","react-image-lightBox": "^5.1.0","react-img-zoom": "^0.1.0","react-imgix": "^7.1.1","react-instantsearch": "^4.5.2","react-mailto": "^0.4.0","react-native": "^0.63.2","react-native-network-info": "^5.2.1","react-owl-carousel": "^2.3.1","react-recaptcha": "^2.3.10","react-redux": "^5.0.5","react-router-dom": "^4.2.2","react-sanfona": "^1.0.6","react-slick": "0.16.0","react-test-renderer": "^16.8.4","redux": "^3.7.0","redux-actions": "^2.3.0","redux-responsive": "^4.3.6","redux-thunk": "^2.2.0","reline": "^1.0.0-beta.3","sitemap": "^2.1.0","soap": "^0.20.0","uglifyjs-webpack-plugin": "^1.2.4","webpack": "^4.44.1","webpack-cli": "^3.3.12","webpack-dev-server": "^3.11.0","yarn": "^1.6.0","zone.js": "^0.8.20"
},"devDependencies": {
"babel-eslint": "^7.2.3","babel-plugin-inline-react-svg": "^0.4.0","babel-plugin-static-fs": "^1.1.0","babel-polyfill": "^6.26.0","core-js": "^3.6.5","eslint-config-xo-react": "^0.12.0","eslint-plugin-react": "^7.1.0","object-assign": "^4.1.1","sw-precache-webpack-plugin": "^0.11.5","xo": "^0.18.1"
},"resolutions": {
"**/**/lodash": "^4.17.12"
},"xo": {
"envs": [
"node","es6","browser"
],"parser": "babel-eslint","extends": "xo-react","space": true,"rules": {
"unicorn/number-literal-case": 0,"no-multi-assign": 1,"array-bracket-spacing": [
2,"always"
],"object-curly-spacing": [
"error","comma-dangle": [
"error","always-multiline"
],"arrow-parens": [
2,"as-needed",{
"requireForBlockBody": true
}
],"operator-linebreak": 0,"capitalized-comments": 0,"react/no-danger": 1,"react/no-array-index-key": 0,"react/jsx-closing-bracket-location": [
2,"tag-aligned"
],"react/jsx-space-before-closing": [
2,"react/jsx-tag-spacing": [
2,{
"beforeSelfClosing": "always"
}
],"react/jsx-no-bind": 0,"react/forbid-component-props": 0,"react/require-default-props": 0,"react/jsx-handler-names": 0
}
}
}
polyfill.js
import includes from 'core-js/features/string/includes'
import repeat from 'core-js/features/string/repeat'
import assign from 'object-assign'
import from from 'core-js/features/array/from'
console.log('Load your polyfills')
// String.prototype.includes = includes
// String.prototype.repeat = repeat
Object.assign = assign
// Array.from = from
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)