问题
我正在尝试在 npm 中发布我自己的 SDK。当我尝试安装软件包时,我的 dist 文件夹仅显示 index.js
代码:
这是我的package.json
文件。它已经包含主文件和文件,https://docs.npmjs.com/cli/v8/using-npm/scripts。
{
"version": "0.1.4",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"engines": {
"node": ">=10"
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test --passWithNoTests",
"lint": "tsdx lint",
"prepare": "tsdx build",
"prepublish": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
},
"peerDependencies": {
"react": ">=16"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"name": "@grammable/sdk",
"author": "peanut butter jelly",
"homepage": …
Run Code Online (Sandbox Code Playgroud) 我尝试在 Next.js 中使用 persistReducer,但我不断收到此错误
error - SyntaxError: Cannot use import statement outside a module
/Users/xx/node_modules/redux-persist/es/persistReducer.js:11
import { FLUSH, PAUSE, PERSIST, PURGE, REHYDRATE, DEFAULT_VERSION } from './constants';
Run Code Online (Sandbox Code Playgroud)
这是我的 _app.tsx 文件,如下所示:
<Providers>
<Container>
<Component {...pageProps} />
</Container>
</Providers>
Run Code Online (Sandbox Code Playgroud)
这是我原来的 store.ts 看起来像:
error - SyntaxError: Cannot use import statement outside a module
/Users/xx/node_modules/redux-persist/es/persistReducer.js:11
import { FLUSH, PAUSE, PERSIST, PURGE, REHYDRATE, DEFAULT_VERSION } from './constants';
Run Code Online (Sandbox Code Playgroud)
这是我尝试将其更改为:
import { configureStore, Action } from "@reduxjs/toolkit"
import { useDispatch } from "react-redux"
import {
persistStore
} from …
Run Code Online (Sandbox Code Playgroud)