我正在尝试在我的angular 7应用程序中包含angular Universal。我已经使用 public static int duplicates(int[] array)
{
if (array.length == 0 || array.length == 1)
return 0;
int numberOfPairs = 0;
for (int i=0;i+1<array.length;i++) {
for (int j=i+1;j<array.length;j++) {
if (array[i] == array[j]) {
numberOfPairs++;
array[j]=array[i+1];
i++;
break;
}
}
}
return numberOfPairs ;
}
运行,但是在节点控制台中出现以下错误。
找不到名称要求。您是否需要为节点安装类型定义?尝试npm i @ types / node`,然后将节点添加到tsconfig中的类型字段
和
找不到名称“进程”。您是否需要为节点安装类型定义?尝试npm i @ types / node,然后将节点添加到tsconfig中的type字段
和
src / server.ts(26,1):错误TS2304:找不到名称“全局”
我的应用程序 webpack.server.config.ts 中包含代码
npm run start-ssr
在我的 tsconfig.json
const path = require('path');
const webpack = require('webpack');
module.exports = {
mode: 'none',
entry: {
server: './server.ts',
},
target: 'node',
resolve: { extensions: ['.ts', '.js'] },
optimization: {
minimize: false
},
output: {
// Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' },
{
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// Removing this will cause deprecation warnings to appear.
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
parser: { system: true },
},
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
}
答案 0 :(得分:0)
您是否按照错误消息中的说明安装了@ types / node?如果没有:
npm i @types/node
然后转到./app/src/tsconfig.server.json
"compilerOptions": { "types": [ "node" ] },
重新启动npm run start-ssr
命令。