尝试构建Angular 8 Universal项目时,我得到以下输出。我使用Webpack和SSR:
myproject/node_modules/universal-analytics/node_modules/uuid/dist/esm-browser/index.js:1
export { default as v1 } from './v1.js';
^^^^^^
**SyntaxError: Unexpected token 'export'**
at wrapSafe (internal/modules/cjs/loader.js:1055:16)
at Module._compile (internal/modules/cjs/loader.js:1103:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
at Module.load (internal/modules/cjs/loader.js:988:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1028:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/myProject/node_modules/universal-analytics/lib/index.js:3:12)
at Module._compile (internal/modules/cjs/loader.js:1139:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
直到今天我必须运行npm install
时,它运行良好。
我的 tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
],
"module": "esnext",
"resolveJsonModule": true
}
}
有没有其他人看到或知道如何解决?
答案 0 :(得分:1)
这似乎是由于NPM缓存了我的一些node_modules,所以当我运行全新的npm i
时,某些模块没有正确更新。我切换到yarn并解决了问题:)